[][src]Struct ulid_generator_rs::ULIDGenerator

pub struct ULIDGenerator { /* fields omitted */ }

This is the ULID Generator.

Implementations

impl ULIDGenerator[src]

#[must_use]pub fn new() -> Self[src]

The Constructor for ULIDGenerator.

pub fn generate(&mut self) -> Result<ULID, ULIDError>[src]

Generate a ULID.

Generate a ULID based on the current time.

Example

use ulid_generator_rs::ULIDGenerator;

let mut generator = ULIDGenerator::new();
let ulid = generator.generate().unwrap();

pub fn generate_monotonic(
    &mut self,
    previous_id: &ULID
) -> Result<ULID, ULIDError>
[src]

Generate a monotonic ULID.

Generate a ULID based on the current time, but if the current is the same timestamp as the previous_id, the lower 64 bits are incremented.

Example

use ulid_generator_rs::ULIDGenerator;

let mut generator = ULIDGenerator::new();
let previous_id = generator.generate().unwrap();
let ulid = generator.generate_monotonic(&previous_id).unwrap();

pub fn generate_strictly_monotonic(
    &mut self,
    previous_id: &ULID
) -> Result<Option<ULID>, ULIDError>
[src]

Generate a strictly monotonic ULID.

If the ULID generated by ULIDGenerator::generate_monotonic is smaller than previous_id, None is returned. Otherwise, the ULID will be returned wrapped in Some.

Example

use ulid_generator_rs::ULIDGenerator;

let mut generator = ULIDGenerator::new();
let prev_id = generator.generate().unwrap();
let ulid = generator.generate_monotonic(&prev_id).unwrap();

Trait Implementations

impl Clone for ULIDGenerator[src]

impl Copy for ULIDGenerator[src]

impl Debug for ULIDGenerator[src]

impl Default for ULIDGenerator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,