Trait newtype_uuid::GenericUuid
source · pub trait GenericUuid {
// Required methods
fn from_untyped_uuid(uuid: Uuid) -> Self
where Self: Sized;
fn into_untyped_uuid(self) -> Uuid
where Self: Sized;
fn as_untyped_uuid(&self) -> &Uuid;
}
Expand description
A trait abstracting over typed and untyped UUIDs.
This can be used to write code that’s generic over TypedUuid
, Uuid
, and other types that
may wrap TypedUuid
(due to e.g. orphan rules).
This trait is similar to From
, but a bit harder to get wrong – in general, the conversion
from and to untyped UUIDs should be careful and explicit.
Required Methods§
sourcefn from_untyped_uuid(uuid: Uuid) -> Selfwhere
Self: Sized,
fn from_untyped_uuid(uuid: Uuid) -> Selfwhere
Self: Sized,
Creates a new instance of Self
from an untyped Uuid
.
sourcefn into_untyped_uuid(self) -> Uuidwhere
Self: Sized,
fn into_untyped_uuid(self) -> Uuidwhere
Self: Sized,
Converts self
into an untyped Uuid
.
sourcefn as_untyped_uuid(&self) -> &Uuid
fn as_untyped_uuid(&self) -> &Uuid
Returns the inner Uuid
.
Generally, into_untyped_uuid
should be preferred. However,
in some cases it may be necessary to use this method to satisfy lifetime constraints.