pub struct Store<Id, C, M>where
C: Codec,{ /* private fields */ }Expand description
In-memory event store that keeps streams in a hash map.
Uses a global sequence counter (Position = u64) to maintain chronological
ordering across streams, enabling cross-aggregate projections that need to
interleave events by time rather than by stream name.
Generic over:
Id: Aggregate identifier type (must be hashable/equatable for map keys)C: Serialization codecM: Metadata type (use()when not needed)
Implementations§
Trait Implementations§
Source§impl<Id, C, M> EventStore for Store<Id, C, M>
impl<Id, C, M> EventStore for Store<Id, C, M>
Source§type Error = InMemoryError
type Error = InMemoryError
Store-specific error type.
fn codec(&self) -> &Self::Codec
Source§fn stream_version<'a>(
&'a self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + 'a
fn stream_version<'a>( &'a self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + 'a
Get the current version (latest position) for an aggregate stream. Read more
Source§fn begin<Conc: ConcurrencyStrategy>(
&mut self,
aggregate_kind: &str,
aggregate_id: Self::Id,
expected_version: Option<Self::Position>,
) -> Transaction<'_, Self, Conc>
fn begin<Conc: ConcurrencyStrategy>( &mut self, aggregate_kind: &str, aggregate_id: Self::Id, expected_version: Option<Self::Position>, ) -> Transaction<'_, Self, Conc>
Begin a transaction for appending events to an aggregate. Read more
Source§fn append<'a>(
&'a mut self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
expected_version: Option<u64>,
events: Vec<PersistableEvent<Self::Metadata>>,
) -> impl Future<Output = Result<(), AppendError<u64, Self::Error>>> + Send + 'a
fn append<'a>( &'a mut self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, expected_version: Option<u64>, events: Vec<PersistableEvent<Self::Metadata>>, ) -> impl Future<Output = Result<(), AppendError<u64, Self::Error>>> + Send + 'a
Append events with optional version checking. Read more
Source§fn append_expecting_new<'a>(
&'a mut self,
aggregate_kind: &'a str,
aggregate_id: &'a Self::Id,
events: Vec<PersistableEvent<Self::Metadata>>,
) -> impl Future<Output = Result<(), AppendError<u64, Self::Error>>> + Send + 'a
fn append_expecting_new<'a>( &'a mut self, aggregate_kind: &'a str, aggregate_id: &'a Self::Id, events: Vec<PersistableEvent<Self::Metadata>>, ) -> impl Future<Output = Result<(), AppendError<u64, Self::Error>>> + Send + 'a
Append events expecting an empty stream. Read more
Source§fn load_events<'a>(
&'a self,
filters: &'a [EventFilter<Self::Id, Self::Position>],
) -> impl Future<Output = Result<Vec<StoredEvent<Id, u64, M>>, Self::Error>> + Send + 'a
fn load_events<'a>( &'a self, filters: &'a [EventFilter<Self::Id, Self::Position>], ) -> impl Future<Output = Result<Vec<StoredEvent<Id, u64, M>>, Self::Error>> + Send + 'a
Load events matching the specified filters. Read more
Auto Trait Implementations§
impl<Id, C, M> Freeze for Store<Id, C, M>where
C: Freeze,
impl<Id, C, M> RefUnwindSafe for Store<Id, C, M>
impl<Id, C, M> Send for Store<Id, C, M>
impl<Id, C, M> Sync for Store<Id, C, M>
impl<Id, C, M> Unpin for Store<Id, C, M>
impl<Id, C, M> UnwindSafe for Store<Id, C, M>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more