Struct newtype_uuid::TypedUuid

source ·
pub struct TypedUuid<T: TypedUuidKind> { /* private fields */ }
Expand description

A UUID with type-level information about what it’s used for.

For more, see the library documentation.

Implementations§

source§

impl<T: TypedUuidKind> TypedUuid<T>

source

pub const fn nil() -> Self

The ‘nil UUID’ (all zeros).

The nil UUID is a special form of UUID that is specified to have all 128 bits set to zero.

§References
source

pub const fn max() -> Self

The ‘max UUID’ (all ones).

The max UUID is a special form of UUID that is specified to have all 128 bits set to one.

§References
source

pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: [u8; 8]) -> Self

Creates a UUID from four field values.

source

pub const fn from_fields_le(d1: u32, d2: u16, d3: u16, d4: [u8; 8]) -> Self

Creates a UUID from four field values in little-endian order.

The bytes in the d1, d2 and d3 fields will be flipped to convert into big-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.

source

pub const fn from_u128(value: u128) -> Self

Creates a UUID from a 128bit value.

source

pub const fn from_u128_le(value: u128) -> Self

Creates a UUID from a 128bit value in little-endian order.

The entire value will be flipped to convert into big-endian order. This is based on the endianness of the UUID, rather than the target environment so bytes will be flipped on both big and little endian machines.

source

pub const fn from_u64_pair(d1: u64, d2: u64) -> Self

Creates a UUID from two 64bit values.

source

pub const fn from_bytes(bytes: Bytes) -> Self

Creates a UUID using the supplied bytes.

source

pub const fn from_bytes_le(bytes: Bytes) -> Self

Creates a UUID using the supplied bytes in little-endian order.

The individual fields encoded in the buffer will be flipped.

source

pub fn new_v4() -> Self

Available on crate feature v4 only.

Creates a new, random UUID v4 of this type.

Trait Implementations§

source§

impl<T: TypedUuidKind> Clone for TypedUuid<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: TypedUuidKind> Debug for TypedUuid<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: TypedUuidKind> Default for TypedUuid<T>

source§

fn default() -> Self

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

impl<'de, T: TypedUuidKind> Deserialize<'de> for TypedUuid<T>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: TypedUuidKind> Display for TypedUuid<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: TypedUuidKind> FromStr for TypedUuid<T>

source§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl<T: TypedUuidKind> GenericUuid for TypedUuid<T>

source§

fn from_untyped_uuid(uuid: Uuid) -> Self

Creates a new instance of Self from an untyped Uuid.
source§

fn into_untyped_uuid(self) -> Uuid

Converts self into an untyped Uuid.
source§

fn as_untyped_uuid(&self) -> &Uuid

Returns the inner Uuid. Read more
source§

impl<T: TypedUuidKind> Hash for TypedUuid<T>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> JsonSchema for TypedUuid<T>

Available on crate feature schemars08 only.

Implements JsonSchema for TypedUuid<T>, if T implements JsonSchema.

  • schema_name is set to "TypedUuidFor", concatenated by the schema name of T.
  • schema_id is set to format!("newtype_uuid::TypedUuid<{}>", T::schema_id()).
  • json_schema is the same as the one for Uuid.
source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl<T: TypedUuidKind> Ord for TypedUuid<T>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: TypedUuidKind> PartialEq for TypedUuid<T>

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: TypedUuidKind> PartialOrd for TypedUuid<T>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: TypedUuidKind> Serialize for TypedUuid<T>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: TypedUuidKind> Copy for TypedUuid<T>

source§

impl<T: TypedUuidKind> Eq for TypedUuid<T>

Auto Trait Implementations§

§

impl<T> Freeze for TypedUuid<T>

§

impl<T> RefUnwindSafe for TypedUuid<T>
where T: RefUnwindSafe,

§

impl<T> Send for TypedUuid<T>

§

impl<T> Sync for TypedUuid<T>

§

impl<T> Unpin for TypedUuid<T>
where T: Unpin,

§

impl<T> UnwindSafe for TypedUuid<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,