newtype_uuid

Trait 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§

source

fn from_untyped_uuid(uuid: Uuid) -> Self
where Self: Sized,

Creates a new instance of Self from an untyped Uuid.

source

fn into_untyped_uuid(self) -> Uuid
where Self: Sized,

Converts self into an untyped Uuid.

source

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.

Implementations on Foreign Types§

source§

impl GenericUuid for Uuid

Implementors§