pub struct OptimisticManager<T> { /* private fields */ }Expand description
Optimistic update manager
Implementations§
Source§impl<T: Clone + Serialize + DeserializeOwned> OptimisticManager<T>
impl<T: Clone + Serialize + DeserializeOwned> OptimisticManager<T>
Sourcepub fn new(config: OptimisticConfig) -> Self
pub fn new(config: OptimisticConfig) -> Self
Create a new optimistic update manager
Sourcepub fn apply_update(
&self,
key: &QueryKey,
data: T,
rollback_data: Option<T>,
) -> String
pub fn apply_update( &self, key: &QueryKey, data: T, rollback_data: Option<T>, ) -> String
Apply an optimistic update
Sourcepub fn get_optimistic_data(&self, key: &QueryKey) -> Option<T>
pub fn get_optimistic_data(&self, key: &QueryKey) -> Option<T>
Get optimistic data for a key
Sourcepub fn confirm_update(&self, update_id: &str) -> Result<(), QueryError>
pub fn confirm_update(&self, update_id: &str) -> Result<(), QueryError>
Confirm an optimistic update
Sourcepub fn rollback_update(&self, update_id: &str) -> Result<Option<T>, QueryError>
pub fn rollback_update(&self, update_id: &str) -> Result<Option<T>, QueryError>
Rollback an optimistic update
Sourcepub fn rollback_key(&self, key: &QueryKey) -> Vec<T>
pub fn rollback_key(&self, key: &QueryKey) -> Vec<T>
Rollback all updates for a specific key
Sourcepub fn rollback_pattern(&self, pattern: &QueryKeyPattern) -> Vec<T>
pub fn rollback_pattern(&self, pattern: &QueryKeyPattern) -> Vec<T>
Rollback all updates matching a pattern
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Clean up expired updates
Sourcepub fn get_active_updates(&self) -> Vec<OptimisticUpdate<T>>
pub fn get_active_updates(&self) -> Vec<OptimisticUpdate<T>>
Get all active updates
Sourcepub fn get_stats(&self) -> OptimisticStats
pub fn get_stats(&self) -> OptimisticStats
Get update statistics
Sourcepub fn clear_history(&self)
pub fn clear_history(&self)
Clear history
Auto Trait Implementations§
impl<T> Freeze for OptimisticManager<T>
impl<T> !RefUnwindSafe for OptimisticManager<T>
impl<T> Send for OptimisticManager<T>
impl<T> Sync for OptimisticManager<T>
impl<T> Unpin for OptimisticManager<T>
impl<T> !UnwindSafe for OptimisticManager<T>
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.