Struct SeqV

Source
pub struct SeqV<M, T = Vec<u8>> {
    pub seq: u64,
    pub meta: Option<M>,
    pub data: T,
}
Expand description

Some value bound with a seq number.

SeqV is the meta-service API level generic value. Meta-service application uses this type to interact with meta-service.

Inside the meta-service, the value is stored in the form of Marked, which could be a tombstone. A Marked::TombStone is converted to None::<SeqV> and a Marked::Normal is converted to Some::<SeqV>.

A Marked::TombStone also has an internal_seq, representing the freshness of the tombstone. internal_seq will be discarded when Marked::TombStone is converted to None::<SeqV>.

Fields§

§seq: u64§meta: Option<M>§data: T

Implementations§

Source§

impl<M, T> SeqV<M, T>

Source

pub fn new(seq: u64, data: T) -> Self

Source

pub fn new_with_meta(seq: u64, meta: Option<M>, data: T) -> Self

Source

pub fn with_seq(self, seq: u64) -> Self

Source

pub fn with_meta(self, m: Option<M>) -> Self

Source

pub fn with_value(self, v: T) -> Self

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> SeqV<M, U>

Convert data to type U and leave seq and meta unchanged.

Source

pub fn try_map<U, E>( self, f: impl FnOnce(T) -> Result<U, E>, ) -> Result<SeqV<M, U>, E>

Try to convert data to type U and leave seq and meta unchanged. f returns an error if the conversion fails.

Trait Implementations§

Source§

impl<M: Clone, T: Clone> Clone for SeqV<M, T>

Source§

fn clone(&self) -> SeqV<M, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M, T> Debug for SeqV<M, T>
where M: Debug, T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: Default, T: Default> Default for SeqV<M, T>

Source§

fn default() -> SeqV<M, T>

Returns the “default value” for a type. Read more
Source§

impl<M, T> Deref for SeqV<M, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<M, T> DerefMut for SeqV<M, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<M, T> From<SeqV<M, T>> for SeqMarked<(Option<M>, T)>

Source§

fn from(value: SeqV<M, T>) -> Self

Converts to this type from the input type.
Source§

impl<M: PartialEq, T: PartialEq> PartialEq for SeqV<M, T>

Source§

fn eq(&self, other: &SeqV<M, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

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.
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). Read more
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).
Source§

impl<M: Eq, T: Eq> Eq for SeqV<M, T>

Source§

impl<M, T> StructuralPartialEq for SeqV<M, T>

Auto Trait Implementations§

§

impl<M, T> Freeze for SeqV<M, T>
where T: Freeze, M: Freeze,

§

impl<M, T> RefUnwindSafe for SeqV<M, T>

§

impl<M, T> Send for SeqV<M, T>
where T: Send, M: Send,

§

impl<M, T> Sync for SeqV<M, T>
where T: Sync, M: Sync,

§

impl<M, T> Unpin for SeqV<M, T>
where T: Unpin, M: Unpin,

§

impl<M, T> UnwindSafe for SeqV<M, T>
where T: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.