pub struct ConcurrentSharedData { /* private fields */ }Expand description
Implementation that handles updates of the given key-value taking into account that race conditions could arise between reading and writing values to the shared memory.
Implementations§
Sourcepub fn new(clock: Rc<dyn Clock>, shared_data: Rc<dyn SharedData>) -> Self
pub fn new(clock: Rc<dyn Clock>, shared_data: Rc<dyn SharedData>) -> Self
Create a new instance.
Sourcepub fn insert<T, F>(
&self,
key: String,
data: T,
handle_consistency: F,
) -> (TransactionStatus, T)
pub fn insert<T, F>( &self, key: String, data: T, handle_consistency: F, ) -> (TransactionStatus, T)
Insert an element, if the element has a different value from the last time it was read, then the function will be invoked to resolve the conflict.
Sourcepub fn update<T, F>(
&self,
key: &str,
update_function: F,
) -> (TransactionStatus, Option<T>)
pub fn update<T, F>( &self, key: &str, update_function: F, ) -> (TransactionStatus, Option<T>)
Updates an element, if the element has a different value from the last time it was read, then the function will be invoked to resolve the conflict.
Sourcepub fn safe_remove(&self, key: &str)
pub fn safe_remove(&self, key: &str)
Remove the element for the given key. This function fails silently.
Trait Implementations§
type Error = Infallible
fn from_context(context: &C) -> Result<Self, Self::Error>
fn from_context_always(context: &C) -> Selfwhere
Self: FromContext<C, E, Error = Infallible>,
Auto Trait Implementations§
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