pub struct Ticker { /* private fields */ }
Expand description

TID Generator

This version uses 53-bit microsecond counter (since UNIX epoch), and a random 10-bit clock id.

If the current timestamp is not greater than the last timestamp (either because clock did not advance monotonically, or multiple TIDs were generated in the same microsecond (very unlikely), the timestamp is simply incremented.

Implementations§

Examples found in repository?
src/identifiers.rs (line 395)
394
395
396
    fn default() -> Self {
        Self::new()
    }
Examples found in repository?
src/identifiers.rs (line 373)
366
367
368
369
370
371
372
373
374
375
    pub fn new() -> Self {
        let mut ticker = Self {
            last_timestamp: 0,
            // mask to 10 bits
            clock_id: rand::random::<u16>() & 0x03FF,
        };
        // prime the pump
        ticker.next_tid();
        ticker
    }

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more