pub struct ConsistencyManager { /* private fields */ }Expand description
Enforces per-session monotonic-read and monotonic-write guarantees.
Sessions are identified by arbitrary string tokens (e.g., client IDs).
Implementations§
Source§impl ConsistencyManager
impl ConsistencyManager
Sourcepub fn new(config: ConsistencyConfig) -> Self
pub fn new(config: ConsistencyConfig) -> Self
Create a new manager with the given configuration.
Sourcepub fn can_read<T>(
&mut self,
session_id: &str,
value: &VersionedValue<T>,
) -> bool
pub fn can_read<T>( &mut self, session_id: &str, value: &VersionedValue<T>, ) -> bool
Determine whether a read of value is acceptable for session_id.
Eventual/ReadYourWrites/Strong/Linearizable: alwaystrueMonotonicRead:value.version >= session's last-seen version
Sourcepub fn after_read<T>(&mut self, session_id: &str, value: &VersionedValue<T>)
pub fn after_read<T>(&mut self, session_id: &str, value: &VersionedValue<T>)
Record that session_id has observed value (update monotonic-read floor).
Sourcepub fn can_write<T>(
&mut self,
session_id: &str,
value: &VersionedValue<T>,
) -> bool
pub fn can_write<T>( &mut self, session_id: &str, value: &VersionedValue<T>, ) -> bool
Determine whether a write of value is valid for session_id.
MonotonicWrite:value.version >= session's last-write version- everything else: always
true
Sourcepub fn after_write<T>(&mut self, session_id: &str, value: &VersionedValue<T>)
pub fn after_write<T>(&mut self, session_id: &str, value: &VersionedValue<T>)
Record that session_id performed a write at value’s version.
Sourcepub fn is_stale<T>(
&self,
value: &VersionedValue<T>,
current_version: u64,
) -> bool
pub fn is_stale<T>( &self, value: &VersionedValue<T>, current_version: u64, ) -> bool
Return true if value.version is strictly behind current_version
(i.e., the value is stale).
Sourcepub fn config(&self) -> &ConsistencyConfig
pub fn config(&self) -> &ConsistencyConfig
Reference to the active configuration.
Sourcepub fn monotonic_read_session_count(&self) -> usize
pub fn monotonic_read_session_count(&self) -> usize
How many sessions are tracked for monotonic-read.
Sourcepub fn monotonic_write_session_count(&self) -> usize
pub fn monotonic_write_session_count(&self) -> usize
How many sessions are tracked for monotonic-write.
Auto Trait Implementations§
impl Freeze for ConsistencyManager
impl RefUnwindSafe for ConsistencyManager
impl Send for ConsistencyManager
impl Sync for ConsistencyManager
impl Unpin for ConsistencyManager
impl UnsafeUnpin for ConsistencyManager
impl UnwindSafe for ConsistencyManager
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.