pub struct InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope,{ /* private fields */ }Expand description
In-memory storage for consensus sessions.
Stores all sessions in RAM using a hash map. This is the default storage implementation and works well for testing or single-node setups. Data is lost when the process exits.
Implementations§
Source§impl<Scope> InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope,
impl<Scope> InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope,
Trait Implementations§
Source§impl<Scope> Clone for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope + Clone,
impl<Scope> Clone for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope + Clone,
Source§fn clone(&self) -> InMemoryConsensusStorage<Scope>
fn clone(&self) -> InMemoryConsensusStorage<Scope>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Scope> ConsensusStorage<Scope> for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope + Clone,
impl<Scope> ConsensusStorage<Scope> for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope + Clone,
Source§async fn save_session(
&self,
scope: &Scope,
session: ConsensusSession,
) -> Result<(), ConsensusError>
async fn save_session( &self, scope: &Scope, session: ConsensusSession, ) -> Result<(), ConsensusError>
Persist a session (insert or overwrite by
proposal_id).Source§async fn get_session(
&self,
scope: &Scope,
proposal_id: u32,
) -> Result<Option<ConsensusSession>, ConsensusError>
async fn get_session( &self, scope: &Scope, proposal_id: u32, ) -> Result<Option<ConsensusSession>, ConsensusError>
Retrieve a session by proposal ID, or
None if it doesn’t exist.Source§async fn remove_session(
&self,
scope: &Scope,
proposal_id: u32,
) -> Result<Option<ConsensusSession>, ConsensusError>
async fn remove_session( &self, scope: &Scope, proposal_id: u32, ) -> Result<Option<ConsensusSession>, ConsensusError>
Remove and return a session, or
None if not found.Source§async fn list_scope_sessions(
&self,
scope: &Scope,
) -> Result<Option<Vec<ConsensusSession>>, ConsensusError>
async fn list_scope_sessions( &self, scope: &Scope, ) -> Result<Option<Vec<ConsensusSession>>, ConsensusError>
List all sessions in a scope, or
None if the scope doesn’t exist.Source§fn stream_scope_sessions<'a>(
&'a self,
scope: &'a Scope,
) -> impl Stream<Item = Result<ConsensusSession, ConsensusError>> + Send + 'a
fn stream_scope_sessions<'a>( &'a self, scope: &'a Scope, ) -> impl Stream<Item = Result<ConsensusSession, ConsensusError>> + Send + 'a
Stream sessions in a scope one at a time (useful for large scopes).
Source§async fn replace_scope_sessions(
&self,
scope: &Scope,
sessions_list: Vec<ConsensusSession>,
) -> Result<(), ConsensusError>
async fn replace_scope_sessions( &self, scope: &Scope, sessions_list: Vec<ConsensusSession>, ) -> Result<(), ConsensusError>
Replace all sessions in a scope atomically.
Source§async fn list_scopes(&self) -> Result<Option<Vec<Scope>>, ConsensusError>
async fn list_scopes(&self) -> Result<Option<Vec<Scope>>, ConsensusError>
List all known scopes, or
None if no scopes exist.Source§async fn update_session<R, F>(
&self,
scope: &Scope,
proposal_id: u32,
mutator: F,
) -> Result<R, ConsensusError>
async fn update_session<R, F>( &self, scope: &Scope, proposal_id: u32, mutator: F, ) -> Result<R, ConsensusError>
Apply a mutation to a single session in place.
Source§async fn update_scope_sessions<F>(
&self,
scope: &Scope,
mutator: F,
) -> Result<(), ConsensusError>
async fn update_scope_sessions<F>( &self, scope: &Scope, mutator: F, ) -> Result<(), ConsensusError>
Apply a mutation to all sessions in a scope (e.g. trimming old entries).
Source§async fn get_scope_config(
&self,
scope: &Scope,
) -> Result<Option<ScopeConfig>, ConsensusError>
async fn get_scope_config( &self, scope: &Scope, ) -> Result<Option<ScopeConfig>, ConsensusError>
Get the scope-level configuration, or
None if not yet initialized.Source§async fn set_scope_config(
&self,
scope: &Scope,
config: ScopeConfig,
) -> Result<(), ConsensusError>
async fn set_scope_config( &self, scope: &Scope, config: ScopeConfig, ) -> Result<(), ConsensusError>
Set (insert or overwrite) the scope-level configuration.
Source§async fn update_scope_config<F>(
&self,
scope: &Scope,
updater: F,
) -> Result<(), ConsensusError>
async fn update_scope_config<F>( &self, scope: &Scope, updater: F, ) -> Result<(), ConsensusError>
Apply a mutation to an existing scope configuration.
Source§impl<Scope> Default for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope,
impl<Scope> Default for InMemoryConsensusStorage<Scope>where
Scope: ConsensusScope,
Auto Trait Implementations§
impl<Scope> Freeze for InMemoryConsensusStorage<Scope>
impl<Scope> !RefUnwindSafe for InMemoryConsensusStorage<Scope>
impl<Scope> Send for InMemoryConsensusStorage<Scope>
impl<Scope> Sync for InMemoryConsensusStorage<Scope>
impl<Scope> Unpin for InMemoryConsensusStorage<Scope>
impl<Scope> !UnwindSafe for InMemoryConsensusStorage<Scope>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more