Struct flaken::Flaken
[−]
[src]
pub struct Flaken { /* fields omitted */ }
Flaken ID generator, encoder, and decoder
Methods
impl Flaken
[src]
fn default() -> Flaken
Build a new flake id with the given node id and other default options node: 0 epoch: 2013-01-01T00:00:00Z in milliseconds since the unix epoch bitwidths (42 timestamp bits, 10 id bits, 12 sequence bits)
fn epoch(self, epoch: u64) -> Flaken
Set the epoch of a Flaken generator
fn node(self, node: u64) -> Flaken
Set the node id of a Flaken generator
fn bitwidths(self, ts_bits: u64, node_bits: u64) -> Flaken
Set the bitwidths of a Flaken generator
fn next(&mut self) -> u64
generate the next id internally this updates at least the current sequence value, possibly the timestamp value if enough time has elapsed to matter
fn encode(&self, ts: u64, node: u64, seq: u64) -> u64
Encode into a flake id the given id, current time, and sequence value
The current time (ts) is the number of milliseconds passed since the unix epoch
fn decode(&self, id: u64) -> (u64, u64, u64)
Decode from an encoded id the timestamp, node id, and sequence id The current time (ts) is the number of milliseconds passed since the unix epoch