pub struct SeqMarked<D = Vec<u8>> { /* private fields */ }Expand description
Sequence-numbered marked value.
Ordered by sequence number first, then tombstone > normal.
use seq_marked::SeqMarked;
let v1 = SeqMarked::new_normal(1, "data");
let v2 = SeqMarked::<&str>::new_tombstone(2);
assert!(v1 < v2);Implementations§
Source§impl<D> SeqMarked<D>
impl<D> SeqMarked<D>
Sourcepub fn new(seq: u64, marked: Marked<D>) -> Self
pub fn new(seq: u64, marked: Marked<D>) -> Self
Creates a new SeqMarked with sequence number and marked data.
Sourcepub fn new_normal(seq: u64, data: D) -> Self
pub fn new_normal(seq: u64, data: D) -> Self
Creates normal value with sequence number.
Sourcepub fn new_tombstone(seq: u64) -> Self
pub fn new_tombstone(seq: u64) -> Self
Creates tombstone with sequence number.
Sourcepub fn new_not_found() -> Self
pub fn new_not_found() -> Self
Represents an absent record (not even marked as deleted).
pub fn to_tombstone(self) -> Self
Sourcepub fn is_tombstone(&self) -> bool
pub fn is_tombstone(&self) -> bool
Returns true if this is a tombstone.
pub fn is_not_found(&self) -> bool
pub fn is_absent(&self) -> bool
Sourcepub fn map<U>(self, f: impl FnOnce(D) -> U) -> SeqMarked<U>
pub fn map<U>(self, f: impl FnOnce(D) -> U) -> SeqMarked<U>
Transforms data D to U while preserving sequence and tombstone state.
§Example
use seq_marked::SeqMarked;
let a = SeqMarked::new_normal(1, "data");
let b = a.map(|x| x.len());
assert_eq!(b.data_ref(), Some(&4));pub fn try_map<U, E>( self, f: impl FnOnce(D) -> Result<U, E>, ) -> Result<SeqMarked<U>, E>
Sourcepub fn order_key(&self) -> SeqMarked<()>
pub fn order_key(&self) -> SeqMarked<()>
Returns ordering key (sequence + tombstone state only).
Sourcepub fn internal_seq(&self) -> InternalSeq
pub fn internal_seq(&self) -> InternalSeq
Returns the sequence number for internal use, tombstone also has a seq.
Sourcepub fn user_seq(&self) -> u64
pub fn user_seq(&self) -> u64
Returns the sequence number for application use, tombstone always has seq 0.
pub fn into_parts(self) -> (u64, Marked<D>)
Sourcepub fn display_with_debug(&self) -> impl Display + '_where
D: Debug,
pub fn display_with_debug(&self) -> impl Display + '_where
D: Debug,
Returns formatter for display using Debug trait.
Trait Implementations§
Source§impl<D: Ord> Ord for SeqMarked<D>
impl<D: Ord> Ord for SeqMarked<D>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<D: PartialOrd> PartialOrd for SeqMarked<D>
impl<D: PartialOrd> PartialOrd for SeqMarked<D>
Source§impl<M, T> SeqValue<M, T> for SeqMarked<(Option<M>, T)>
impl<M, T> SeqValue<M, T> for SeqMarked<(Option<M>, T)>
Source§fn into_value(self) -> Option<T>
fn into_value(self) -> Option<T>
Consume the value and return the value.
Source§fn unpack(self) -> (u64, Option<V>)where
Self: Sized,
fn unpack(self) -> (u64, Option<V>)where
Self: Sized,
Consume self and return the sequence number and the value.
Source§fn expires_at_ms_opt(&self) -> Option<u64>where
M: Expirable,
fn expires_at_ms_opt(&self) -> Option<u64>where
M: Expirable,
Return the absolute expire time in millisecond since 1970-01-01 00:00:00.
impl<D: Copy> Copy for SeqMarked<D>
impl<D: Eq> Eq for SeqMarked<D>
impl<D> StructuralPartialEq for SeqMarked<D>
Auto Trait Implementations§
impl<D> Freeze for SeqMarked<D>where
D: Freeze,
impl<D> RefUnwindSafe for SeqMarked<D>where
D: RefUnwindSafe,
impl<D> Send for SeqMarked<D>where
D: Send,
impl<D> Sync for SeqMarked<D>where
D: Sync,
impl<D> Unpin for SeqMarked<D>where
D: Unpin,
impl<D> UnwindSafe for SeqMarked<D>where
D: UnwindSafe,
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