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>
impl<T: TypedUuidKind> TypedUuid<T>
Sourcepub const fn nil() -> Self
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
Sourcepub const fn max() -> Self
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
Sourcepub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: [u8; 8]) -> Self
pub const fn from_fields(d1: u32, d2: u16, d3: u16, d4: [u8; 8]) -> Self
Creates a UUID from four field values.
Sourcepub const fn from_fields_le(d1: u32, d2: u16, d3: u16, d4: [u8; 8]) -> Self
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.
Sourcepub const fn from_u128_le(value: u128) -> Self
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.
Sourcepub const fn from_u64_pair(d1: u64, d2: u64) -> Self
pub const fn from_u64_pair(d1: u64, d2: u64) -> Self
Creates a UUID from two 64bit values.
Sourcepub const fn from_bytes(bytes: Bytes) -> Self
pub const fn from_bytes(bytes: Bytes) -> Self
Creates a UUID using the supplied bytes.
Sourcepub const fn from_bytes_le(bytes: Bytes) -> Self
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.
Sourcepub fn new_v4() -> Self
Available on crate feature v4
only.
pub fn new_v4() -> Self
v4
only.Creates a new, random UUID v4 of this type.
Sourcepub const fn get_version_num(&self) -> usize
pub const fn get_version_num(&self) -> usize
Returns the version number of the UUID.
This represents the algorithm used to generate the value.
This method is the future-proof alternative to Self::get_version
.
§References
Sourcepub fn get_version(&self) -> Option<Version>
pub fn get_version(&self) -> Option<Version>
Returns the version of the UUID.
This represents the algorithm used to generate the value.
If the version field doesn’t contain a recognized version then None
is returned. If you’re trying to read the version for a future extension
you can also use Uuid::get_version_num
to unconditionally return a
number. Future extensions may start to return Some
once they’re
standardized and supported.
§References
Trait Implementations§
Source§impl<T> Arbitrary for TypedUuid<T>where
T: TypedUuidKind,
Available on crate feature proptest1
only.
impl<T> Arbitrary for TypedUuid<T>where
T: TypedUuidKind,
proptest1
only.Generates random TypedUuid<T>
instances.
Currently, this always returns a version 4 UUID. Support for other kinds
of UUIDs might be added via Self::Parameters
in the future.
Source§type Parameters = TypedUuidParams
type Parameters = TypedUuidParams
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.Source§type Strategy = BoxedStrategy<TypedUuid<T>>
type Strategy = BoxedStrategy<TypedUuid<T>>
Strategy
used to generate values of type Self
.Source§fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy
Source§impl<T: TypedUuidKind> Clone for TypedUuid<T>
impl<T: TypedUuidKind> Clone for TypedUuid<T>
Source§impl<T: TypedUuidKind> Debug for TypedUuid<T>
impl<T: TypedUuidKind> Debug for TypedUuid<T>
Source§impl<T: TypedUuidKind> Default for TypedUuid<T>
impl<T: TypedUuidKind> Default for TypedUuid<T>
Source§impl<'de, T: TypedUuidKind> Deserialize<'de> for TypedUuid<T>
impl<'de, T: TypedUuidKind> Deserialize<'de> for TypedUuid<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: TypedUuidKind> Display for TypedUuid<T>
impl<T: TypedUuidKind> Display for TypedUuid<T>
Source§impl<T: TypedUuidKind> FromStr for TypedUuid<T>
impl<T: TypedUuidKind> FromStr for TypedUuid<T>
Source§impl<T: TypedUuidKind> GenericUuid for TypedUuid<T>
impl<T: TypedUuidKind> GenericUuid for TypedUuid<T>
Source§impl<T: TypedUuidKind> Hash for TypedUuid<T>
impl<T: TypedUuidKind> Hash for TypedUuid<T>
Source§impl<T> JsonSchema for TypedUuid<T>where
T: TypedUuidKind + JsonSchema,
Available on crate feature schemars08
only.
impl<T> JsonSchema for TypedUuid<T>where
T: TypedUuidKind + JsonSchema,
schemars08
only.Implements JsonSchema
for TypedUuid<T>
, if T
implements JsonSchema
.
schema_name
is set to"TypedUuidFor"
, concatenated by the schema name ofT
.schema_id
is set toformat!("newtype_uuid::TypedUuid<{}>", T::schema_id())
.json_schema
is the same as the one forUuid
.
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more