Trait SnowflakeGenerator

Source
pub trait SnowflakeGenerator<ID, T>
where ID: Snowflake, T: TimeSource<ID::Ty>,
{ // Required methods fn new(machine_id: ID::Ty, clock: T) -> Self; fn next_id(&self) -> IdGenStatus<ID>; fn try_next_id(&self) -> Result<IdGenStatus<ID>>; }
Expand description

A minimal interface for generating Snowflake IDs

Required Methods§

Source

fn new(machine_id: ID::Ty, clock: T) -> Self

Source

fn next_id(&self) -> IdGenStatus<ID>

Returns the next available ID

Source

fn try_next_id(&self) -> Result<IdGenStatus<ID>>

A fallible version of Self::next_id that returns a Result.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<ID, T> SnowflakeGenerator<ID, T> for AtomicSnowflakeGenerator<ID, T>
where ID: Snowflake<Ty = u64>, T: TimeSource<ID::Ty>,

Source§

impl<ID, T> SnowflakeGenerator<ID, T> for BasicSnowflakeGenerator<ID, T>
where ID: Snowflake, T: TimeSource<ID::Ty>,

Source§

impl<ID, T> SnowflakeGenerator<ID, T> for LockSnowflakeGenerator<ID, T>
where ID: Snowflake, T: TimeSource<ID::Ty>,