pub trait LocalSnapshotStore: Clone + 'static {
    type Id: Debug;
    type Error: StdError + Send + Sync + 'static;

    // Required methods
    async fn save<S, ToBytes, ToBytesError>(
        &mut self,
        id: &Self::Id,
        seq_no: NonZeroU64,
        state: &S,
        to_bytes: &ToBytes
    ) -> Result<(), Self::Error>
       where S: Send + Sync,
             ToBytes: Fn(&S) -> Result<Bytes, ToBytesError> + Sync,
             ToBytesError: StdError + Send + Sync + 'static;
    async fn load<S, FromBytes, FromBytesError>(
        &self,
        id: &Self::Id,
        from_bytes: FromBytes
    ) -> Result<Option<Snapshot<S>>, Self::Error>
       where FromBytes: Fn(Bytes) -> Result<S, FromBytesError> + Send,
             FromBytesError: StdError + Send + Sync + 'static;
}
Expand description

Persistence for snapshots.

Required Associated Types§

source

type Id: Debug

source

type Error: StdError + Send + Sync + 'static

Required Methods§

source

async fn save<S, ToBytes, ToBytesError>( &mut self, id: &Self::Id, seq_no: NonZeroU64, state: &S, to_bytes: &ToBytes ) -> Result<(), Self::Error>
where S: Send + Sync, ToBytes: Fn(&S) -> Result<Bytes, ToBytesError> + Sync, ToBytesError: StdError + Send + Sync + 'static,

Save the given snapshot state for the given entity ID and sequence number.

source

async fn load<S, FromBytes, FromBytesError>( &self, id: &Self::Id, from_bytes: FromBytes ) -> Result<Option<Snapshot<S>>, Self::Error>
where FromBytes: Fn(Bytes) -> Result<S, FromBytesError> + Send, FromBytesError: StdError + Send + Sync + 'static,

Find and possibly load the Snapshot for the given entity ID.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> LocalSnapshotStore for T
where T: SnapshotStore,

§

type Id = <T as SnapshotStore>::Id

§

type Error = <T as SnapshotStore>::Error