pub trait EventStore: Send + Sync {
// Required methods
fn append_event(
&self,
draft: EventDraft,
) -> BoxFuture<'_, Result<EventRecord, StoreError>>;
fn history(
&self,
query: HistoryQuery,
) -> BoxFuture<'_, Result<Vec<EventRecord>, StoreError>>;
fn audit_page(
&self,
print_id: PrintId,
after: Option<EventId>,
page_size: u32,
) -> BoxFuture<'_, Result<AuditPage, StoreError>>;
}Expand description
The event log.
Every method is asynchronous, the trait is dyn-compatible, and it is
shareable across threads, because its consumers hold it behind
Arc<dyn EventStore>.
Required Methods§
Sourcefn append_event(
&self,
draft: EventDraft,
) -> BoxFuture<'_, Result<EventRecord, StoreError>>
fn append_event( &self, draft: EventDraft, ) -> BoxFuture<'_, Result<EventRecord, StoreError>>
Append one event, minting its identifier.
Sourcefn history(
&self,
query: HistoryQuery,
) -> BoxFuture<'_, Result<Vec<EventRecord>, StoreError>>
fn history( &self, query: HistoryQuery, ) -> BoxFuture<'_, Result<Vec<EventRecord>, StoreError>>
Read a print’s events, newest first.
Answers newest first. An empty kinds means every kind rather
than no kinds. An absent limit takes DEFAULT_HISTORY_WINDOW, and a
limit above MAX_HISTORY_LIMIT is refused rather than clamped —
resolve_history_limit is the one resolution of that rule.
Sourcefn audit_page(
&self,
print_id: PrintId,
after: Option<EventId>,
page_size: u32,
) -> BoxFuture<'_, Result<AuditPage, StoreError>>
fn audit_page( &self, print_id: PrintId, after: Option<EventId>, page_size: u32, ) -> BoxFuture<'_, Result<AuditPage, StoreError>>
Read one page of a print’s whole history, oldest first.
after is the identifier of the last event of the previous page, and is
absent for the first page. The page size is resolved by
resolve_history_limit like a history read’s limit, so a page above
MAX_HISTORY_LIMIT is refused rather than clamped.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".