pub struct Oid<P> { /* private fields */ }
Expand description
A Typed Object ID where the Prefix is part of the type
§Examples
A nice property of this two different prefix are two different types, and thus the following fails to compile:
ⓘ
struct A;
impl OidPrefix for A {}
struct B;
impl OidPrefix for B {}
// The same UUID for both
let oid_a: Oid<A> = Oid::try_with_uuid("b3cfdafa-3fec-41e2-82bf-ff881131abf1").unwrap();
let oid_b: Oid<B> = Oid::try_with_uuid("b3cfdafa-3fec-41e2-82bf-ff881131abf1").unwrap();
// This fails to compile because `Oid<A>` is a different type than `Oid<B>` and no
// PartialEq or Eq is implemented between these two types.
oid_a == oid_b
Implementations§
Source§impl<P: OidPrefix> Oid<P>
impl<P: OidPrefix> Oid<P>
Sourcepub fn new_v4() -> Self
Available on crate feature uuid_v4
only.
pub fn new_v4() -> Self
uuid_v4
only.Create a new Oid
with a UUIDv4 (random)
Sourcepub fn new_v7_now() -> Self
Available on crate feature uuid_v7
only.
pub fn new_v7_now() -> Self
uuid_v7
only.Create a new Oid
with a UUIDv7 (UNIX Epoch based for current system
clock)
Sourcepub fn new_v7(ts: Timestamp) -> Self
Available on crate feature uuid_v7
only.
pub fn new_v7(ts: Timestamp) -> Self
uuid_v7
only.Create a new Oid
with a UUIDv7 (UNIX Epoch based)
Sourcepub fn try_with_uuid<S: AsRef<str>>(uuid: S) -> Result<Self>
pub fn try_with_uuid<S: AsRef<str>>(uuid: S) -> Result<Self>
Attempts to create a new Oid with a given string-ish UUID
Sourcepub fn try_with_uuid_base32<S: AsRef<str>>(base32_uuid: S) -> Result<Self>
pub fn try_with_uuid_base32<S: AsRef<str>>(base32_uuid: S) -> Result<Self>
Attemp to create an Oid from a base32hex encoded UUID string-ish value
Trait Implementations§
Source§impl<'de, P: OidPrefix> Deserialize<'de> for Oid<P>
Available on crate feature serde
only.
impl<'de, P: OidPrefix> Deserialize<'de> for Oid<P>
Available on crate feature
serde
only.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>,
Deserialize this value from the given Serde deserializer. Read more
impl<P> Copy for Oid<P>
impl<P: Eq> Eq for Oid<P>
impl<P> StructuralPartialEq for Oid<P>
Auto Trait Implementations§
impl<P> Freeze for Oid<P>
impl<P> RefUnwindSafe for Oid<P>
impl<P> Send for Oid<P>
impl<P> Sync for Oid<P>
impl<P> Unpin for Oid<P>
impl<P> UnwindSafe for Oid<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more