pub struct SeqMarked<D = Vec<u8>> { /* private fields */ }Expand description
Sequence-numbered marked value.
Ordered by sequence number first, then tombstone > normal.
use seqmarked::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_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 is_tombstone(&self) -> bool
pub fn is_tombstone(&self) -> bool
Returns true if this is a tombstone.
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 seqmarked::SeqMarked;
let a = SeqMarked::new_normal(1, "data");
let b = a.map(|x| x.len());
assert_eq!(b.data_ref(), Some(&4));Sourcepub fn order_key(&self) -> SeqMarked<()>
pub fn order_key(&self) -> SeqMarked<()>
Returns ordering key (sequence + tombstone state only).
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>
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