pub struct ValidityTs(/* private fields */);Expand description
Reverse-ordered validity timestamp for efficient disk-storage scans.
Wraps a signed 64-bit timestamp with reversed ordering so that newer timestamps sort before older ones in byte-ordered storage.
§Key Encoding
Use versioned_key to produce a 16-byte key
combining an entity ID with a validity timestamp. The entity ID sorts
in natural order, while the timestamp sorts in reverse order within
each entity, so a forward scan returns the newest version first.
Implementations§
Source§impl ValidityTs
impl ValidityTs
Sourcepub fn current() -> Self
pub fn current() -> Self
Returns a sentinel value representing “always current.”
Uses i64::MAX so it sorts before every real timestamp in
reverse order.
Sourcepub fn versioned_key(entity_id: u64, ts: Self) -> [u8; 16]
pub fn versioned_key(entity_id: u64, ts: Self) -> [u8; 16]
Encodes an entity ID and validity timestamp into a 16-byte key.
Layout: [entity_id: 8 bytes BE][timestamp: 8 bytes BE]
Because ValidityTs uses Reverse<i64>, the timestamp bytes
are the raw i64 in big-endian. To get reverse-sorted timestamps
in byte order, callers should negate or bitwise-complement the
timestamp before creating the ValidityTs. For a simpler approach,
use i64::MAX - epoch as the timestamp value.
Sourcepub fn from_versioned_key(key: &[u8; 16]) -> (u64, Self)
pub fn from_versioned_key(key: &[u8; 16]) -> (u64, Self)
Decodes entity ID and timestamp from a 16-byte versioned key.
Returns (entity_id, ValidityTs).
Trait Implementations§
Source§impl Clone for ValidityTs
impl Clone for ValidityTs
Source§fn clone(&self) -> ValidityTs
fn clone(&self) -> ValidityTs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidityTs
impl Debug for ValidityTs
Source§impl From<i64> for ValidityTs
impl From<i64> for ValidityTs
Source§impl Hash for ValidityTs
impl Hash for ValidityTs
Source§impl Ord for ValidityTs
impl Ord for ValidityTs
Source§impl PartialEq for ValidityTs
impl PartialEq for ValidityTs
Source§impl PartialOrd for ValidityTs
impl PartialOrd for ValidityTs
impl Copy for ValidityTs
impl Eq for ValidityTs
impl StructuralPartialEq for ValidityTs
Auto Trait Implementations§
impl Freeze for ValidityTs
impl RefUnwindSafe for ValidityTs
impl Send for ValidityTs
impl Sync for ValidityTs
impl Unpin for ValidityTs
impl UnsafeUnpin for ValidityTs
impl UnwindSafe for ValidityTs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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
key and return true if they are equal.