Struct idable::TimestampSeq
source · pub struct TimestampSeq { /* private fields */ }Expand description
Represents a timestamped sequence generator.
Implementations§
source§impl TimestampSeq
impl TimestampSeq
sourcepub fn new() -> TimestampSeq
pub fn new() -> TimestampSeq
Creates a new TimestampSeq instance with default values.
sourcepub fn next_id(&mut self) -> u64
pub fn next_id(&mut self) -> u64
Generates the next unique ID based on the timestamp and sequence number.
The generated ID is a combination of timestamp and sequence number, ensuring uniqueness.
- Note that it is not guaranteed to be in increasing order。
§Examples
use idable::TimestampSeq;
let mut timestamp_seq = TimestampSeq::new();
// Generate the next unique ID.
let unique_id = timestamp_seq.next_id();
// Print the generated unique ID.
println!("Generated Unique ID: {}", unique_id);Trait Implementations§
source§impl Default for TimestampSeq
impl Default for TimestampSeq
source§fn default() -> TimestampSeq
fn default() -> TimestampSeq
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for TimestampSeq
impl Send for TimestampSeq
impl Sync for TimestampSeq
impl Unpin for TimestampSeq
impl UnwindSafe for TimestampSeq
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