[−][src]Struct avocado::uid::Uid
A newtype wrapper to provide type safety for unique IDs of Doc
uments
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]
impl<T: Doc> Uid<T>
pub fn from_raw(raw: T::Id) -> Self
[src]
pub fn from_raw(raw: T::Id) -> Self
Creates a strongly-typed Uid<T>
from a raw representation.
pub fn into_raw(self) -> T::Id
[src]
pub fn into_raw(self) -> T::Id
Converts the strongly-typed Uid<T>
into its raw representation.
impl<T: Doc<Id = ObjectId>> Uid<T>
[src]
impl<T: Doc<Id = ObjectId>> Uid<T>
Convenience methods for ObjectId
-valued Uid
s.
pub fn new_oid() -> Result<Self, Error>
[src]
pub fn new_oid() -> Result<Self, Error>
Generates a new ObjectId
-valued unique ID.
pub fn from_oid_bytes(bytes: [u8; 12]) -> Self
[src]
pub fn from_oid_bytes(bytes: [u8; 12]) -> Self
Constructs a wrapper around an ObjectId
represented by raw bytes.
pub fn from_oid_str(s: &str) -> Result<Self, Error>
[src]
pub fn from_oid_str(s: &str) -> Result<Self, Error>
Creates an ObjectID
-valued Uid
using a 12-byte (24-char)
hexadecimal string.
impl<T: Doc<Id = Uuid>> Uid<T>
[src]
impl<T: Doc<Id = Uuid>> Uid<T>
Convenience methods for Uuid
-valued Uid
s.
pub fn new_uuid() -> Self
[src]
pub fn new_uuid() -> Self
Creates a new random (v4) UUID-backed ID.
pub fn from_uuid_bytes(bytes: [u8; 16]) -> Self
[src]
pub fn from_uuid_bytes(bytes: [u8; 16]) -> Self
Creates a Uid
backed by a Uuid
of the exact bytes specified.
pub fn from_random_uuid_bytes(bytes: [u8; 16]) -> Self
[src]
pub fn from_random_uuid_bytes(bytes: [u8; 16]) -> Self
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> Ord for Uid<T> where
T::Id: Ord,
[src]
impl<T: Doc> Ord for Uid<T> where
T::Id: Ord,
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: Doc> PartialEq<Uid<T>> for Uid<T>
[src]
impl<T: Doc> PartialEq<Uid<T>> for Uid<T>
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
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: Into<Bson>,
impl<T: Doc, '_> From<&'_ Uid<T>> for Bson where
T::Id: ToOwned,
<T::Id as ToOwned>::Owned: Into<Bson>,
[src]
impl<T: Doc, '_> From<&'_ Uid<T>> for Bson where
T::Id: ToOwned,
<T::Id as ToOwned>::Owned: Into<Bson>,
impl<T: Doc> Clone for Uid<T> where
T::Id: Clone,
[src]
impl<T: Doc> Clone for Uid<T> where
T::Id: Clone,
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Doc> Copy for Uid<T> where
T::Id: Copy,
[src]
impl<T: Doc> Copy for Uid<T> where
T::Id: Copy,
impl<T: Doc> Eq for Uid<T>
[src]
impl<T: Doc> Eq for Uid<T>
impl<T: Doc> PartialOrd<Uid<T>> for Uid<T> where
T::Id: PartialOrd,
[src]
impl<T: Doc> PartialOrd<Uid<T>> for Uid<T> where
T::Id: PartialOrd,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
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]
#[must_use]
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
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
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]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Doc> AsRef<<T as Doc>::Id> for Uid<T>
[src]
impl<T: Doc> AsRef<<T as Doc>::Id> for Uid<T>
impl<T: Doc> Default for Uid<T> where
T::Id: Default,
[src]
impl<T: Doc> Default for Uid<T> where
T::Id: Default,
impl<T: Doc> Display for Uid<T> where
T::Id: Display,
[src]
impl<T: Doc> Display for Uid<T> where
T::Id: Display,
impl<T: Doc> Debug for Uid<T> where
T::Id: Debug,
[src]
impl<T: Doc> Debug for Uid<T> where
T::Id: Debug,
impl<T: Doc> FromStr for Uid<T> where
T::Id: FromStr,
[src]
impl<T: Doc> FromStr for Uid<T> where
T::Id: FromStr,
type Err = <T::Id as FromStr>::Err
The associated error which can be returned from parsing.
fn from_str(string: &str) -> Result<Self, Self::Err>
[src]
fn from_str(string: &str) -> Result<Self, Self::Err>
impl<T: Doc> Hash for Uid<T> where
T::Id: Hash,
[src]
impl<T: Doc> Hash for Uid<T> where
T::Id: Hash,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, T: Doc> Deserialize<'a> for Uid<T>
[src]
impl<'a, T: Doc> Deserialize<'a> for Uid<T>
fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>
[src]
fn deserialize<D: Deserializer<'a>>(deserializer: D) -> Result<Self, D::Error>
impl<T: Doc> Serialize for Uid<T>
[src]
impl<T: Doc> Serialize for Uid<T>
impl<T: Doc> BsonSchema for Uid<T> where
T::Id: BsonSchema,
[src]
impl<T: Doc> BsonSchema for Uid<T> where
T::Id: BsonSchema,
fn bson_schema() -> Document
[src]
fn bson_schema() -> Document
Auto Trait Implementations
impl<T> Send for Uid<T> where
<T as Doc>::Id: Send,
impl<T> Send for Uid<T> where
<T as Doc>::Id: Send,
impl<T> Sync for Uid<T> where
<T as Doc>::Id: Sync,
impl<T> Sync for Uid<T> where
<T as Doc>::Id: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> ToHex for T where
T: AsRef<[u8]>,
impl<T> ToHex for T where
T: AsRef<[u8]>,
fn write_hex<W>(&self, w: &mut W) -> Result<(), Error> where
W: Write,
fn write_hex<W>(&self, w: &mut W) -> Result<(), Error> where
W: Write,
fn write_hex_upper<W>(&self, w: &mut W) -> Result<(), Error> where
W: Write,
fn write_hex_upper<W>(&self, w: &mut W) -> Result<(), Error> where
W: Write,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
impl<'a, T> TryFrom for T where
T: FromStr,
impl<'a, T> TryFrom for T where
T: FromStr,
type Err = <T as FromStr>::Err
fn try_from(string: &'a str) -> Result<T, <T as TryFrom<&'a str>>::Err>
fn try_from(string: &'a str) -> Result<T, <T as TryFrom<&'a str>>::Err>
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
fn equivalent(&self, key: &K) -> bool
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T, U> TryInto for T where
U: TryFrom<T>,
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self