pub struct Snowflake<S: Storage> { /* private fields */ }Expand description
Snowflake-based unique ID generator.
Implementations§
Source§impl<S: Storage> Snowflake<S>
impl<S: Storage> Snowflake<S>
Sourcepub async fn new(
config: SnowflakeConfig,
storage: Arc<S>,
) -> Result<Self, SnowflakeError>
pub async fn new( config: SnowflakeConfig, storage: Arc<S>, ) -> Result<Self, SnowflakeError>
Create a new Snowflake generator.
Sourcepub async fn generate_u64(&self) -> Result<u64, SnowflakeError>
pub async fn generate_u64(&self) -> Result<u64, SnowflakeError>
Generate a new unique ID as u64.
Source§impl Snowflake<MemoryStorage>
impl Snowflake<MemoryStorage>
Sourcepub fn with_default() -> Self
pub fn with_default() -> Self
Create a Snowflake generator with default configuration and memory storage.
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for Snowflake<S>
impl<S> !RefUnwindSafe for Snowflake<S>
impl<S> Send for Snowflake<S>
impl<S> Sync for Snowflake<S>
impl<S> Unpin for Snowflake<S>
impl<S> UnsafeUnpin for Snowflake<S>
impl<S> !UnwindSafe for Snowflake<S>
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