Skip to main content

Store

Trait Store 

Source
pub trait Store: Send {
    // Required methods
    fn origin(&self) -> &Origin;
    fn get(&self, id: &RecordId) -> Result<Option<Record>>;
    fn history(&self, id: &RecordId) -> Result<Vec<Event>>;
    fn event_by_idempotency_key(&self, key: &str) -> Result<Option<Event>>;
    fn commit(&mut self, event: Event, snapshot: Record) -> Result<()>;
    fn list(&self, query: &RecordQuery) -> Result<Vec<Record>>;
    fn incoming(&self, target: &RecordId) -> Result<Vec<IncomingEdge>>;
}

Required Methods§

Source

fn origin(&self) -> &Origin

The authority this store mints identifiers for.

Source

fn get(&self, id: &RecordId) -> Result<Option<Record>>

Current snapshot of a record.

Source

fn history(&self, id: &RecordId) -> Result<Vec<Event>>

Full history of a record, ordered by sequence.

Source

fn event_by_idempotency_key(&self, key: &str) -> Result<Option<Event>>

Source

fn commit(&mut self, event: Event, snapshot: Record) -> Result<()>

Atomically append event and replace the snapshot with snapshot.

Must fail with crate::Error::Conflict unless event.sequence is exactly one more than the stored version, and with crate::Error::IdempotencyConflict if the event’s idempotency key is already used. When event is a redaction, earlier events of the record must be scrubbed with crate::event::scrub_event in the same transaction.

Source

fn list(&self, query: &RecordQuery) -> Result<Vec<Record>>

Records matching the query, newest first.

Source

fn incoming(&self, target: &RecordId) -> Result<Vec<IncomingEdge>>

Relations (including retracted ones) whose target is target.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§