pub struct PersistedSnowflakeGenerator<T> { /* private fields */ }
Expand description
Persisted SnowflakeGenerator
.
Designed for easier contextualization.
§Thread safety
YES. You can use ::std::sync::Arc
to send data between threads safety.
§Clone
Clone is cheap. If you clone it, it equals invoke Arc::clone
three times.
Implementations§
Source§impl<T> PersistedSnowflakeGenerator<T>
impl<T> PersistedSnowflakeGenerator<T>
Sourcepub fn new(generator: Arc<SnowflakeGenerator>, provider: Arc<T>) -> Self
pub fn new(generator: Arc<SnowflakeGenerator>, provider: Arc<T>) -> Self
Constructing new PersistedSnowflakeGenerator
from already instanced SnowflakeGenerator
and TimeProvider
The cost very low, please relax to constructing your PersistedSnowflakeGenerator
.
§Thread safety
Yes, time_provider
must be send and sync between threads and SnowflakeGenerator
are already thread safe.
Sourcepub fn assign_sync(&self) -> Snowflake
pub fn assign_sync(&self) -> Snowflake
Assign a new Snowflake
but in synchronous way.
Trait Implementations§
Source§impl<T> Clone for PersistedSnowflakeGenerator<T>
impl<T> Clone for PersistedSnowflakeGenerator<T>
Auto Trait Implementations§
impl<T> Freeze for PersistedSnowflakeGenerator<T>
impl<T> RefUnwindSafe for PersistedSnowflakeGenerator<T>where
T: RefUnwindSafe,
impl<T> Send for PersistedSnowflakeGenerator<T>
impl<T> Sync for PersistedSnowflakeGenerator<T>
impl<T> Unpin for PersistedSnowflakeGenerator<T>
impl<T> UnwindSafe for PersistedSnowflakeGenerator<T>where
T: RefUnwindSafe,
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