Struct canonical::Id [−][src]
pub struct Id { /* fields omitted */ }
Expand description
This is the Id type, that uniquely identifies slices of bytes,
in rust equivalent to &[u8]
. As in the case with &[u8]
the length is
also encoded in the type, making it a kind of a fat-pointer for content
adressed byteslices.
The length of the corresponding bytestring is encoed in the first two bytes in big endian.
If the length of the byteslice is less than or equal to 32 bytes, the bytes
are stored directly inline in the bytes
field.
Proposal: The trailing bytes in an inlined value MUST be set to zero
Implementations
impl Id
[src]
impl Id
[src]pub fn hash(&self) -> IdHash
[src]
pub fn hash(&self) -> IdHash
[src]Returns the computed hash of the value.
Note that this is different from the payload itself in case of an inlined value, that normally does not get hashed.
Useful for giving a well-distributed unique id for all Canon
types,
for use in hash maps for example.
pub fn into_payload(self) -> [u8; 32]
[src]
pub fn into_payload(self) -> [u8; 32]
[src]Consumes the Id and returns the payload bytes
pub fn reify<T>(&self) -> Result<T, CanonError> where
T: Canon,
[src]
pub fn reify<T>(&self) -> Result<T, CanonError> where
T: Canon,
[src]Attempts to reify the Id as an instance of type T
pub fn take_bytes(&self) -> Result<Option<Vec<u8>>, CanonError>
[src]
pub fn take_bytes(&self) -> Result<Option<Vec<u8>>, CanonError>
[src]Takes the bytes corresponding to this id out of the underlying store.
If the Id is inlined, this is a no-op and returns Ok(None)
Trait Implementations
impl<'a> Arbitrary<'a> for Id
[src]
impl<'a> Arbitrary<'a> for Id
[src]fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
[src]
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
[src]Generate an arbitrary value of Self
from the given unstructured data. Read more
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
[src]
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
[src]Generate an arbitrary value of Self
from the entirety of the given unstructured data. Read more
impl Ord for Id
[src]
impl Ord for Id
[src]impl PartialOrd<Id> for Id
[src]
impl PartialOrd<Id> for Id
[src]fn partial_cmp(&self, other: &Id) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Id) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[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]
#[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
impl Copy for Id
[src]
impl Eq for Id
[src]
impl StructuralEq for Id
[src]
impl StructuralPartialEq for Id
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more