pub struct EpochPhaseState {
pub epoch: u64,
pub phase: Phase,
}Expand description
CRDT state combining an epoch counter with a lifecycle phase.
The epoch increases on reopen operations, ensuring that reopens always win against concurrent operations in earlier epochs.
Fields§
§epoch: u64Monotonically increasing epoch counter. Incremented on reopen.
phase: PhaseCurrent lifecycle phase within this epoch.
Implementations§
Source§impl EpochPhaseState
impl EpochPhaseState
Sourcepub const fn with(epoch: u64, phase: Phase) -> Self
pub const fn with(epoch: u64, phase: Phase) -> Self
Create a state with specific epoch and phase.
Sourcepub fn advance(&mut self, target: Phase) -> Result<(), StateError>
pub fn advance(&mut self, target: Phase) -> Result<(), StateError>
Advance to a new phase within the current epoch.
Returns Err if the target phase has a lower rank than the current
phase (within the same epoch, phases only move forward).
§Errors
Returns StateError::InvalidTransition if the target phase has
a rank equal to or lower than the current phase.
Trait Implementations§
Source§impl Clone for EpochPhaseState
impl Clone for EpochPhaseState
Source§fn clone(&self) -> EpochPhaseState
fn clone(&self) -> EpochPhaseState
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 Debug for EpochPhaseState
impl Debug for EpochPhaseState
Source§impl Default for EpochPhaseState
impl Default for EpochPhaseState
Source§impl<'de> Deserialize<'de> for EpochPhaseState
impl<'de> Deserialize<'de> for EpochPhaseState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EpochPhaseState
impl Display for EpochPhaseState
Source§impl Hash for EpochPhaseState
impl Hash for EpochPhaseState
Source§impl PartialEq for EpochPhaseState
impl PartialEq for EpochPhaseState
Source§impl Serialize for EpochPhaseState
impl Serialize for EpochPhaseState
impl Eq for EpochPhaseState
impl StructuralPartialEq for EpochPhaseState
Auto Trait Implementations§
impl Freeze for EpochPhaseState
impl RefUnwindSafe for EpochPhaseState
impl Send for EpochPhaseState
impl Sync for EpochPhaseState
impl Unpin for EpochPhaseState
impl UnsafeUnpin for EpochPhaseState
impl UnwindSafe for EpochPhaseState
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.