SeqValue

Trait SeqValue 

Source
pub trait SeqValue<M, V = Vec<u8>> {
    // Required methods
    fn seq(&self) -> u64;
    fn value(&self) -> Option<&V>;
    fn into_value(self) -> Option<V>;
    fn meta(&self) -> Option<&M>;

    // Provided methods
    fn unpack(self) -> (u64, Option<V>)
       where Self: Sized { ... }
    fn expires_at_ms_opt(&self) -> Option<u64>
       where M: Expirable { ... }
    fn expires_at_ms(&self) -> u64
       where M: Expirable { ... }
    fn is_expired(&self, now_ms: u64) -> bool
       where M: Expirable { ... }
}
Expand description

Trait for a value with a sequence number and metadata.

SeqValue is intended for application use and does not include a tombstone concept, unlike SeqMarked which is for LSM internals.

Required Methods§

Source

fn seq(&self) -> u64

Return the sequence number of the value.

Source

fn value(&self) -> Option<&V>

Return the reference of the value.

Source

fn into_value(self) -> Option<V>

Consume the value and return the value.

Source

fn meta(&self) -> Option<&M>

Return the reference of metadata of the value.

Provided Methods§

Source

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,

Return the absolute expire time in millisecond since 1970-01-01 00:00:00.

Source

fn expires_at_ms(&self) -> u64
where M: Expirable,

Returns the absolute expiration time in milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

If no expiration time is set, returns u64::MAX, effectively meaning the value never expires. This method provides a consistent way to handle both expiring and non-expiring values.

Source

fn is_expired(&self, now_ms: u64) -> bool
where M: Expirable,

Return true if the record is expired at the given time in milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

Implementations on Foreign Types§

Source§

impl<M, V> SeqValue<M, V> for Option<SeqV<M, V>>

Source§

fn seq(&self) -> u64

Source§

fn value(&self) -> Option<&V>

Source§

fn into_value(self) -> Option<V>

Source§

fn meta(&self) -> Option<&M>

Implementors§

Source§

impl<M, T> SeqValue<M, T> for SeqMarked<(Option<M>, T)>

SeqMarked is a superset of SeqValue.

Source§

impl<M, V> SeqValue<M, V> for SeqV<M, V>