Trait eventsourced::LocalEvtLog
source · pub trait LocalEvtLog: Clone + 'static {
type Id: Debug;
type Error: StdError + Send + Sync + 'static;
const MAX_SEQ_NO: NonZeroU64 = NonZeroU64::MAX;
// Required methods
async fn persist<E, ToBytes, ToBytesError>(
&mut self,
evt: &E,
type_name: &str,
id: &Self::Id,
last_seq_no: Option<NonZeroU64>,
to_bytes: &ToBytes
) -> Result<NonZeroU64, Self::Error>
where E: Debug + Sync,
ToBytes: Fn(&E) -> Result<Bytes, ToBytesError> + Sync,
ToBytesError: StdError + Send + Sync + 'static;
async fn last_seq_no(
&self,
type_name: &str,
id: &Self::Id
) -> Result<Option<NonZeroU64>, Self::Error>;
async fn evts_by_id<E, FromBytes, FromBytesError>(
&self,
type_name: &str,
id: &Self::Id,
after_seq_no: Option<NonZeroU64>,
from_bytes: FromBytes
) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
where E: Send,
FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static,
FromBytesError: StdError + Send + Sync + 'static;
async fn evts_by_type<E, FromBytes, FromBytesError>(
&self,
type_name: &str,
after_seq_no: Option<NonZeroU64>,
from_bytes: FromBytes
) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
where E: Send,
FromBytes: Fn(Bytes) -> Result<E, FromBytesError> + Copy + Send + Sync + 'static,
FromBytesError: StdError + Send + Sync + 'static;
}Expand description
Persistence for events.
Required Associated Types§
Provided Associated Constants§
sourceconst MAX_SEQ_NO: NonZeroU64 = NonZeroU64::MAX
const MAX_SEQ_NO: NonZeroU64 = NonZeroU64::MAX
The maximum value for sequence numbers. Defaults to NonZeroU64::MAX unless overriden by an
implementation.
Required Methods§
sourceasync fn persist<E, ToBytes, ToBytesError>(
&mut self,
evt: &E,
type_name: &str,
id: &Self::Id,
last_seq_no: Option<NonZeroU64>,
to_bytes: &ToBytes
) -> Result<NonZeroU64, Self::Error>
async fn persist<E, ToBytes, ToBytesError>( &mut self, evt: &E, type_name: &str, id: &Self::Id, last_seq_no: Option<NonZeroU64>, to_bytes: &ToBytes ) -> Result<NonZeroU64, Self::Error>
Persist the given event and optional tag for the given entity type and ID and return the sequence number for the persisted event. The given last sequence number is used for optimistic locking, i.e. it must match the current last sequence number of the event log.
sourceasync fn last_seq_no(
&self,
type_name: &str,
id: &Self::Id
) -> Result<Option<NonZeroU64>, Self::Error>
async fn last_seq_no( &self, type_name: &str, id: &Self::Id ) -> Result<Option<NonZeroU64>, Self::Error>
Get the last sequence number for the given entity type and ID.
sourceasync fn evts_by_id<E, FromBytes, FromBytesError>(
&self,
type_name: &str,
id: &Self::Id,
after_seq_no: Option<NonZeroU64>,
from_bytes: FromBytes
) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
async fn evts_by_id<E, FromBytes, FromBytesError>( &self, type_name: &str, id: &Self::Id, after_seq_no: Option<NonZeroU64>, from_bytes: FromBytes ) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
Get the events for the given entity ID starting after the given sequence number.
sourceasync fn evts_by_type<E, FromBytes, FromBytesError>(
&self,
type_name: &str,
after_seq_no: Option<NonZeroU64>,
from_bytes: FromBytes
) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
async fn evts_by_type<E, FromBytes, FromBytesError>( &self, type_name: &str, after_seq_no: Option<NonZeroU64>, from_bytes: FromBytes ) -> Result<impl Stream<Item = Result<(NonZeroU64, E), Self::Error>> + Send, Self::Error>
Get the events for the given entity type starting after the given sequence number.
Object Safety§
This trait is not object safe.