pub struct VersionedContext {
pub current: DistributedContext,
pub history: Vec<ContextSnapshot>,
pub max_history: usize,
pub resolution_strategy: ConflictResolution,
}Expand description
A versioned context with history tracking
Fields§
§current: DistributedContextCurrent context
history: Vec<ContextSnapshot>Version history (limited to last N versions)
max_history: usizeMaximum history size
resolution_strategy: ConflictResolutionConflict resolution strategy
Implementations§
Source§impl VersionedContext
impl VersionedContext
Sourcepub fn with_config(
session_id: impl Into<String>,
max_history: usize,
strategy: ConflictResolution,
) -> Self
pub fn with_config( session_id: impl Into<String>, max_history: usize, strategy: ConflictResolution, ) -> Self
Create with custom settings
Sourcepub fn update(&mut self, new_context: DistributedContext) -> Result<()>
pub fn update(&mut self, new_context: DistributedContext) -> Result<()>
Update the context and save to history
Sourcepub fn merge_with_resolution(
&mut self,
other: &DistributedContext,
) -> Result<()>
pub fn merge_with_resolution( &mut self, other: &DistributedContext, ) -> Result<()>
Merge another context with conflict resolution
Sourcepub fn get_version(&self, version: u64) -> Option<&ContextSnapshot>
pub fn get_version(&self, version: u64) -> Option<&ContextSnapshot>
Get a specific version from history
Sourcepub fn rollback_to(&mut self, version: u64) -> Result<()>
pub fn rollback_to(&mut self, version: u64) -> Result<()>
Rollback to a previous version
Sourcepub fn get_history(&self) -> &[ContextSnapshot]
pub fn get_history(&self) -> &[ContextSnapshot]
Get version history
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear history
Trait Implementations§
Source§impl Clone for VersionedContext
impl Clone for VersionedContext
Source§fn clone(&self) -> VersionedContext
fn clone(&self) -> VersionedContext
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 moreAuto Trait Implementations§
impl Freeze for VersionedContext
impl RefUnwindSafe for VersionedContext
impl Send for VersionedContext
impl Sync for VersionedContext
impl Unpin for VersionedContext
impl UnwindSafe for VersionedContext
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