pub struct Uuid { /* private fields */ }
Expand description
A struct modeling a BSON UUID value (i.e. a Binary value with subtype 4).
This type should be used instead of uuid::Uuid
when serializing to or deserializing from BSON, since
uuid::Uuid
’s serde
implementation doesn’t
produce or parse BSON UUIDs.
To enable interop with the Uuid
type from the uuid
crate, enable the uuid-0_8
feature
flag.
For more information on the usage of this type, see the uuid
module-level documentation.
Note: due to an issue in serde (see here), this type
will also allow deserialization from 16 byte + subtype 0 Binary values in BSON if part of a
#[serde(flatten)]
chain. This behavior shouldn’t be relied upon as it may be fixed at some
point in the future.
Implementations
sourceimpl Uuid
impl Uuid
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a random UUID.
This uses the operating system’s RNG as the source of random numbers. If you’d like to use a
custom generator, generate random bytes and pass them to Uuid::from_bytes
instead.
sourcepub const fn from_bytes(bytes: [u8; 16]) -> Self
pub const fn from_bytes(bytes: [u8; 16]) -> Self
Creates a Uuid
using the supplied big-endian bytes.
sourceimpl Uuid
impl Uuid
sourcepub fn from_uuid_0_8(uuid: Uuid) -> Self
Available on crate feature uuid-0_8
only.
pub fn from_uuid_0_8(uuid: Uuid) -> Self
uuid-0_8
only.Create a Uuid
from a uuid::Uuid
from
the uuid
crate.
sourcepub fn to_uuid_0_8(self) -> Uuid
Available on crate feature uuid-0_8
only.
pub fn to_uuid_0_8(self) -> Uuid
uuid-0_8
only.Convert this Uuid
to a uuid::Uuid
from
the uuid
crate.
sourceimpl Uuid
impl Uuid
sourcepub fn from_uuid_1(uuid: Uuid) -> Self
Available on crate feature uuid-1
only.
pub fn from_uuid_1(uuid: Uuid) -> Self
uuid-1
only.Create a Uuid
from a uuid::Uuid
from
the uuid
crate.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Uuid
impl<'de> Deserialize<'de> for Uuid
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'de> DeserializeAs<'de, Uuid> for Uuid
Available on crate features uuid-0_8
and serde_with
only.
impl<'de> DeserializeAs<'de, Uuid> for Uuid
uuid-0_8
and serde_with
only.sourcefn deserialize_as<D>(deserializer: D) -> Result<Uuid, D::Error> where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<Uuid, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer.
sourceimpl<'de> DeserializeAs<'de, Uuid> for Uuid
Available on crate features uuid-1
and serde_with
only.
impl<'de> DeserializeAs<'de, Uuid> for Uuid
uuid-1
and serde_with
only.sourcefn deserialize_as<D>(deserializer: D) -> Result<Uuid, D::Error> where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<Uuid, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer.
sourceimpl Ord for Uuid
impl Ord for Uuid
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Uuid> for Uuid
impl PartialOrd<Uuid> for Uuid
sourcefn partial_cmp(&self, other: &Uuid) -> Option<Ordering>
fn partial_cmp(&self, other: &Uuid) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SerializeAs<Uuid> for Uuid
Available on crate features uuid-0_8
and serde_with
only.
impl SerializeAs<Uuid> for Uuid
uuid-0_8
and serde_with
only.sourcefn serialize_as<S>(source: &Uuid, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
fn serialize_as<S>(source: &Uuid, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer.
sourceimpl SerializeAs<Uuid> for Uuid
Available on crate features uuid-1
and serde_with
only.
impl SerializeAs<Uuid> for Uuid
uuid-1
and serde_with
only.sourcefn serialize_as<S>(source: &Uuid, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
fn serialize_as<S>(source: &Uuid, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer.
impl Copy for Uuid
impl Eq for Uuid
impl StructuralEq for Uuid
impl StructuralPartialEq for Uuid
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.