[][src]Struct lolid::Uuid

pub struct Uuid { /* fields omitted */ }

Universally unique identifier, consisting of 128-bits, as according to RFC4122

Implementations

impl Uuid[src]

pub const fn nil() -> Self[src]

Creates zero UUID

pub const fn from_bytes(data: [u8; 16]) -> Self[src]

Creates new Uuid from raw bytes.

pub const fn as_bytes(&self) -> &[u8][src]

Access underlying bytes as slice.

pub const fn bytes(&self) -> [u8; 16][src]

Get underlying raw bytes

pub const fn is_version(&self, version: Version) -> bool[src]

Checks if UUID version is equal to the provided version

pub const fn is_variant(&self) -> bool[src]

Checks if UUID variant is set, only cares about RFC4122 byte

pub const fn v1(timestamp: Timestamp, mac: [u8; 6]) -> Self[src]

Generates UUID from time and mac address

pub fn v4() -> Self[src]

Generates UUID v4 using OS RNG from getrandom

Only available when osrng feature is enabled.

pub fn prng() -> Self[src]

Generates UUID v4 using PRNG from wyhash

Only available when prng feature is enabled.

This random variant generates predictable UUID, even though they are unique. Which means that each time program starts, it is initialized with the same seed and therefore would repeat UUIDs

This random is useful when you want to generate predictable but unique UUIDs Otherwise use v4

pub fn v5(namespace: Uuid, name: &[u8]) -> Self[src]

Generates UUID v5 by using sha1 hasher

Only available when sha1 feature is enabled.

pub const fn set_variant(self) -> Self[src]

Adds variant byte to the corresponding field.

This implementation only cares about RFC4122, there is no option to set other variant.

Useful when user is supplied with random bytes, and wants to create UUID from it.

pub const fn set_version(self, version: Version) -> Self[src]

Adds version byte to the corresponding field.

Useful when user is supplied with random bytes, and wants to create UUID from it.

pub fn parse_ascii_bytes(input: &[u8]) -> Result<Self, ParseError>[src]

Creates new instance by parsing provided bytes.

Use this when you want to avoid performing utf-8 checks and directly feed bytes. As long as supplied bytes contain valid ascii characters it will parse successfully. Otherwise it shall fail with invalid character.

Supports only simple sequence of characters and - separated.

pub fn parse_str(input: &str) -> Result<Self, ParseError>[src]

Creates new instance by parsing provided string.

Supports only simple sequence of characters and - separated.

pub const fn to_str(&self) -> StrBuf<[u8; 36]>[src]

Creates textual representation of UUID in a static buffer.

Trait Implementations

impl AsRef<[u8]> for Uuid[src]

impl Clone for Uuid[src]

impl Copy for Uuid[src]

impl Debug for Uuid[src]

impl Default for Uuid[src]

impl<'de> Deserialize<'de> for Uuid[src]

impl Display for Uuid[src]

impl Eq for Uuid[src]

impl FromStr for Uuid[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl Hash for Uuid[src]

impl Ord for Uuid[src]

impl PartialEq<Uuid> for Uuid[src]

impl PartialOrd<Uuid> for Uuid[src]

impl Serialize for Uuid[src]

impl StructuralEq for Uuid[src]

impl StructuralPartialEq for Uuid[src]

Auto Trait Implementations

impl RefUnwindSafe for Uuid

impl Send for Uuid

impl Sync for Uuid

impl Unpin for Uuid

impl UnwindSafe for Uuid

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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> ToString for T where
    T: Display + ?Sized
[src]

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.