Skip to main content

Id

Struct Id 

Source
pub struct Id {
    pub ms: u64,
    pub seq: u64,
}
Expand description

An entry ID, which is a millisecond and a sequence number inside it.

Two 64 bit halves rather than one 128 bit number, because both halves are addressable on the wire: XADD key 5-* asks for the next sequence inside millisecond five, and XRANGE key 5 5 is every sequence inside it.

Fields§

§ms: u64

The millisecond, which is a unix timestamp for an ID the server made up.

§seq: u64

Which entry within that millisecond.

Implementations§

Source§

impl Id

Source

pub const MIN: Id

The lowest ID there is, which is what - means in a range.

Source

pub const MAX: Id

The highest, which is what + means.

Source

pub const fn new(ms: u64, seq: u64) -> Id

An ID from its two halves.

Source

pub const fn next(self) -> Option<Id>

The next ID after this one, or None at Id::MAX.

What an exclusive range start turns into, and what XADD key ms-* resolves to when the millisecond is already the last one used.

Source

pub const fn prev(self) -> Option<Id>

The ID before this one, or None at Id::MIN.

Source

pub fn to_bytes(self) -> [u8; 16]

The sixteen big endian bytes Redis keys a node by.

Big endian because that is the order that sorts, which is the whole reason the format picked it.

Source

pub fn from_bytes(bytes: [u8; 16]) -> Id

The ID those bytes hold.

Source

pub fn write_to(self, out: &mut Vec<u8>)

ms-seq, which is how an ID looks everywhere a client can see one.

Source

pub fn to_vec(self) -> Vec<u8>

The same as a fresh Vec, for a caller that is not building a reply.

Source

pub fn parse(s: &[u8], default: u64) -> Option<Id>

ms or ms-seq, with a missing sequence read as default.

XRANGE key 5 5 means every entry in millisecond five, so the start defaults its sequence to zero and the end to the largest there is. The special forms a client can send, -, +, $, * and ms-*, are the command layer’s business and not this one’s.

Trait Implementations§

Source§

impl Clone for Id

Source§

fn clone(&self) -> Id

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Id

Source§

impl Debug for Id

Source§

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

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

impl Default for Id

Source§

fn default() -> Id

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

impl Eq for Id

Source§

impl Ord for Id

Source§

fn cmp(&self, other: &Id) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Id

Source§

fn eq(&self, other: &Id) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Id

Source§

fn partial_cmp(&self, other: &Id) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Id

Auto Trait Implementations§

§

impl Freeze for Id

§

impl RefUnwindSafe for Id

§

impl Send for Id

§

impl Sync for Id

§

impl Unpin for Id

§

impl UnsafeUnpin for Id

§

impl UnwindSafe for Id

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.