pub struct SnowflakeIdBucket { /* private fields */ }
Expand description

The SnowflakeIdBucket type is snowflake-id-bucket it easy to get id also have a id buffer.

Implementations

Constructs a new SnowflakeIdBucket using the UNIX epoch. Please make sure that machine_id and node_id is small than 32(2^5);

Examples
use snowflake::SnowflakeIdBucket;

let id_generator_bucket = SnowflakeIdBucket::new(1, 1);

Constructs a new SnowflakeIdBucket using the specified epoch. Please make sure that machine_id and node_id is small than 32(2^5);

Examples
use std::time::{Duration, UNIX_EPOCH};
use snowflake::SnowflakeIdBucket;

// 1 January 2015 00:00:00
let discord_epoch = UNIX_EPOCH + Duration::from_millis(1420070400000);
let id_generator_bucket = SnowflakeIdBucket::with_epoch(1, 1, discord_epoch);

Generate id.

Examples
use snowflake::SnowflakeIdBucket;

let mut id_generator_bucket = SnowflakeIdBucket::new(1, 1);
let id = id_generator_bucket.get_id();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.