pub struct AtomicOption;Expand description
Provides methods for configuring global settings for atomic-id.
Use this struct to manage the global epoch for timestamp-based ID generation.
Implementations§
Source§impl AtomicOption
impl AtomicOption
Sourcepub fn epoch(ms: u64)
pub fn epoch(ms: u64)
Set the global custom epoch for timestamp-based IDs.
The epoch is the point in time from which the timestamp portion of an ID is measured. Setting a more recent epoch can extend the lifespan of the generator.
§Arguments
ms- The epoch timestamp in milliseconds since the UNIX epoch.
§Example
use atomic_id::AtomicOption;
// Set the epoch to January 1, 2024
AtomicOption::epoch(1704067200000);Sourcepub fn get_epoch() -> u64
pub fn get_epoch() -> u64
Get the current global epoch value.
§Returns
The current epoch in milliseconds since the UNIX epoch.
Sourcepub fn reset_epoch()
pub fn reset_epoch()
Reset the global epoch to its default value (2022-05-01 00:00:00 UTC).
Auto Trait Implementations§
impl Freeze for AtomicOption
impl RefUnwindSafe for AtomicOption
impl Send for AtomicOption
impl Sync for AtomicOption
impl Unpin for AtomicOption
impl UnwindSafe for AtomicOption
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