[][src]Struct avocado::uid::Uid

pub struct Uid<T: Doc>(_);

A newtype wrapper to provide type safety for unique IDs of Documents that share the same underlying raw ID type.

It serializes and deserializes transparently as if it were a value of type <T as Doc>::Id.

Methods

impl<T: Doc> Uid<T>
[src]

pub fn from_raw(raw: T::Id) -> Self
[src]

Creates a strongly-typed Uid<T> from a raw representation.

pub fn into_raw(self) -> T::Id
[src]

Converts the strongly-typed Uid<T> into its raw representation.

impl<T: Doc<Id = ObjectId>> Uid<T>
[src]

Convenience methods for ObjectId-valued Uids.

pub fn new_oid() -> Result<Self, Error>
[src]

Generates a new ObjectId-valued unique ID.

pub fn from_oid_bytes(bytes: [u8; 12]) -> Self
[src]

Constructs a wrapper around an ObjectId represented by raw bytes.

pub fn from_oid_str(s: &str) -> Result<Self, Error>
[src]

Creates an ObjectID-valued Uid using a 12-byte (24-char) hexadecimal string.

impl<T: Doc<Id = Uuid>> Uid<T>
[src]

Convenience methods for Uuid-valued Uids.

pub fn new_uuid() -> Self
[src]

Creates a new random (v4) UUID-backed ID.

pub fn from_uuid_bytes(bytes: [u8; 16]) -> Self
[src]

Creates a Uid backed by a Uuid of the exact bytes specified.

pub fn from_random_uuid_bytes(bytes: [u8; 16]) -> Self
[src]

Creates a Uid backed by a Uuid based on the bytes supplied, modified so that the result is a valid v4 variant.

Trait Implementations

impl<T: Doc> From<Uid<T>> for Bson where
    T::Id: Into<Bson>, 
[src]

impl<T: Doc, '_> From<&'_ Uid<T>> for Bson where
    T::Id: ToOwned,
    <T::Id as ToOwned>::Owned: Into<Bson>, 
[src]

impl<T: Doc> Eq for Uid<T>
[src]

impl<T: Doc> PartialOrd<Uid<T>> for Uid<T> where
    T::Id: PartialOrd
[src]

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: Doc> Copy for Uid<T> where
    T::Id: Copy
[src]

impl<T: Doc> Default for Uid<T> where
    T::Id: Default
[src]

impl<T: Doc> PartialEq<Uid<T>> for Uid<T>
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<T: Doc> AsRef<<T as Doc>::Id> for Uid<T>
[src]

impl<T: Doc> Clone for Uid<T> where
    T::Id: Clone
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Doc> Ord for Uid<T> where
    T::Id: Ord
[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl<T: Doc> Debug for Uid<T> where
    T::Id: Debug
[src]

impl<T: Doc> Display for Uid<T> where
    T::Id: Display
[src]

impl<T: Doc> Hash for Uid<T> where
    T::Id: Hash
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Doc> FromStr for Uid<T> where
    T::Id: FromStr
[src]

type Err = <T::Id as FromStr>::Err

The associated error which can be returned from parsing.

impl<'a, T: Doc> Deserialize<'a> for Uid<T>
[src]

impl<T: Doc> Serialize for Uid<T>
[src]

impl<T: Doc> BsonSchema for Uid<T> where
    T::Id: BsonSchema
[src]

Auto Trait Implementations

impl<T> Send for Uid<T> where
    <T as Doc>::Id: Send

impl<T> Sync for Uid<T> where
    <T as Doc>::Id: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToHex for T where
    T: AsRef<[u8]>, 

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<'a, T> TryFrom for T where
    T: FromStr

type Err = <T as FromStr>::Err

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> Same for T

type Output = T

Should always be Self