pub struct State {
pub last_ts: SystemTime,
pub node_id: NodeId,
pub seq: u16,
}
Fields§
§last_ts: SystemTime
§node_id: NodeId
§seq: u16
Implementations§
Source§impl State
impl State
Sourcepub fn next(&mut self, timestamp: SystemTime) -> (SystemTime, u16)
pub fn next(&mut self, timestamp: SystemTime) -> (SystemTime, u16)
This method returns the next [UUID
]’s timestamp and clock sequence.
- Increments this
State
’s timestamp by 100 ns, - compares this with the timestamp provided,
- if the provided timestamp is greater or equal, the clock sequence is incremented,
- the timestamp and clock sequence are returned.
§Usage
use ps_uuid::STATE;
use std::time::SystemTime;
let (timestamp, clock_seq) = STATE.lock().next(SystemTime::now());
Source§impl State
impl State
Sourcepub fn next_v7(&mut self, timestamp: SystemTime) -> SystemTime
pub fn next_v7(&mut self, timestamp: SystemTime) -> SystemTime
This method returns the next UUIDv7
’s timestamp.
- Increments this
State
’s timestamp by 256 ns, - compares this with the timestamp provided, keeping the greater of the two,
- replaces this
State
’s timestamp with the value, - returns the value.
§Usage
use ps_uuid::STATE;
use std::time::SystemTime;
let next_ts = STATE.lock().next_v7(SystemTime::now());
Trait Implementations§
Source§impl Ord for State
impl Ord for State
Source§impl PartialOrd for State
impl PartialOrd for State
impl Copy for State
impl Eq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
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