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§
Source§impl SnowflakeIdBucket
impl SnowflakeIdBucket
Sourcepub fn new(machine_id: i32, node_id: i32) -> Self
pub fn new(machine_id: i32, node_id: i32) -> Self
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);Sourcepub fn with_epoch(machine_id: i32, node_id: i32, epoch: SystemTime) -> Self
pub fn with_epoch(machine_id: i32, node_id: i32, epoch: SystemTime) -> Self
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);Trait Implementations§
Source§impl Clone for SnowflakeIdBucket
impl Clone for SnowflakeIdBucket
Source§fn clone(&self) -> SnowflakeIdBucket
fn clone(&self) -> SnowflakeIdBucket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SnowflakeIdBucket
impl RefUnwindSafe for SnowflakeIdBucket
impl Send for SnowflakeIdBucket
impl Sync for SnowflakeIdBucket
impl Unpin for SnowflakeIdBucket
impl UnwindSafe for SnowflakeIdBucket
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