pub struct SnowflakeGenerator { /* private fields */ }Expand description
Lock-free monotonic 64-bit Snowflake ID generator safe for multi-threaded sharing.
Implementations§
Source§impl SnowflakeGenerator
Lock-free ID generation methods for SnowflakeGenerator.
impl SnowflakeGenerator
Lock-free ID generation methods for SnowflakeGenerator.
Sourcepub fn get_epoch_ms(&self) -> u64
pub fn get_epoch_ms(&self) -> u64
Returns the configured custom epoch in Unix milliseconds.
§Returns
u64- Custom epoch timestamp in milliseconds.
Sourcepub fn get_node_id(&self) -> u16
pub fn get_node_id(&self) -> u16
Sourcepub fn next_id(&self) -> SnowflakeId
pub fn next_id(&self) -> SnowflakeId
Generates the next strictly monotonic 64-bit Snowflake ID using wall-clock time.
Uses a single lock-free AtomicU64 compare-exchange loop; clock rollbacks or
intra-millisecond sequence exhaustion advance the logical millisecond monotonically
without blocking or panicking.
§Returns
SnowflakeId- A unique, strictly increasing Snowflake identifier.
Sourcepub fn next_id_at(&self, now_unix_ms: u64) -> SnowflakeId
pub fn next_id_at(&self, now_unix_ms: u64) -> SnowflakeId
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SnowflakeGenerator
impl Forget for SnowflakeGenerator
impl Move for SnowflakeGenerator
impl RefUnwindSafe for SnowflakeGenerator
impl Send for SnowflakeGenerator
impl Sync for SnowflakeGenerator
impl Unpin for SnowflakeGenerator
impl UnsafeUnpin for SnowflakeGeneratorwhere
Align8<u64>: UnsafeUnpin,
impl UnwindSafe for SnowflakeGeneratorwhere
Align8<u64>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more