Struct oysterpack_uid::uid::Uid[][src]

pub struct Uid<T: ?Sized> { /* fields omitted */ }

Represents a ULID for some type T.

By default, Uid is serializable via serde. If serialization is not needed then you can opt out by including the dependency with default features disabled : default-features = false.

Examples

Uid for structs

struct Domain;
type DomainId = Uid<Domain>;
let id = DomainId::new();

Uid for traits

trait Foo{}
// traits are not Send. Send is added to the type def in order to satisfy Uid type constraints
// in order to be able to send the Uid across threads
type FooId = Uid<dyn Foo + Send + Sync>;
let id = FooId::new();

Methods

impl<T: 'static + ?Sized> Uid<T>
[src]

New Uid instances are guaranteed to be lexographically sortable if they are created within the same millisecond. In other words, Uid(s) created within the same millisecond are random.

Creates the next strictly monotonic ULID for the given previous ULID. Returns None if the random part of the next ULID would overflow.

returns the id

Returns the timestamp of this ULID as a DateTime.

Returns a new ULID with the random part incremented by one. Returns None if the new ULID overflows.

Trait Implementations

impl<T: 'static> Serialize for Uid<T>
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de, T: 'static> Deserialize<'de> for Uid<T>
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<T: 'static + ?Sized> Display for Uid<T>
[src]

Formats the value using the given formatter. Read more

impl<T: 'static + ?Sized> PartialEq for Uid<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: 'static + ?Sized> PartialOrd for Uid<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: 'static + ?Sized> Eq for Uid<T>
[src]

impl<T: 'static + ?Sized> Ord for Uid<T>
[src]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl<T: 'static + ?Sized> Hash for Uid<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: 'static + ?Sized> Copy for Uid<T>
[src]

impl<T: 'static + ?Sized> Clone for Uid<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: 'static + ?Sized> Debug for Uid<T>
[src]

Formats the value using the given formatter. Read more

impl<T: 'static + ?Sized> From<[u8; 16]> for Uid<T>
[src]

Performs the conversion.

impl<T: 'static + ?Sized> From<u128> for Uid<T>
[src]

Performs the conversion.

impl<T: 'static + ?Sized> From<(u64, u64)> for Uid<T>
[src]

Performs the conversion.

impl<T: 'static + ?Sized> FromStr for Uid<T>
[src]

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

impl<T: 'static + ?Sized> From<Uid<T>> for u128
[src]

Performs the conversion.

impl<T: 'static + ?Sized> From<Uid<T>> for (u64, u64)
[src]

Performs the conversion.

Auto Trait Implementations

impl<T: ?Sized> Send for Uid<T> where
    T: Send

impl<T: ?Sized> Sync for Uid<T> where
    T: Sync