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: u64The millisecond, which is a unix timestamp for an ID the server made up.
seq: u64Which entry within that millisecond.
Implementations§
Source§impl Id
impl Id
Sourcepub const fn next(self) -> Option<Id>
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.
Sourcepub fn to_bytes(self) -> [u8; 16]
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.
Sourcepub fn from_bytes(bytes: [u8; 16]) -> Id
pub fn from_bytes(bytes: [u8; 16]) -> Id
The ID those bytes hold.
Sourcepub fn write_to(self, out: &mut Vec<u8>)
pub fn write_to(self, out: &mut Vec<u8>)
ms-seq, which is how an ID looks everywhere a client can see one.
Sourcepub fn to_vec(self) -> Vec<u8> ⓘ
pub fn to_vec(self) -> Vec<u8> ⓘ
The same as a fresh Vec, for a caller that is not building a reply.
Sourcepub fn parse(s: &[u8], default: u64) -> Option<Id>
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.