pub struct Reference(/* private fields */);Expand description
A globally unique reference to a globally unique object
Implementations§
Source§impl Reference
impl Reference
pub const REFERENCE_SIZE: usize = 32usize
Sourcepub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
pub fn from_data_ref(data: impl AsRef<[u8]>) -> Result<Self>
Create a new reference from data.
Returns None if the data is not the correct length.
Sourcepub fn from_digest(digest: Digest) -> Self
pub fn from_digest(digest: Digest) -> Self
Create a new reference from the given digest.
Sourcepub fn from_hex(hex: impl AsRef<str>) -> Self
pub fn from_hex(hex: impl AsRef<str>) -> Self
Create a new reference from the given hexadecimal string.
§Panics
Panics if the string is not exactly 64 hexadecimal digits.
Sourcepub fn ref_data_short(&self) -> [u8; 4]
pub fn ref_data_short(&self) -> [u8; 4]
The first four bytes of the reference
Sourcepub fn ref_hex_short(&self) -> String
pub fn ref_hex_short(&self) -> String
The first four bytes of the reference as a hexadecimal string.
Sourcepub fn bytewords_identifier(&self, prefix: Option<&str>) -> String
pub fn bytewords_identifier(&self, prefix: Option<&str>) -> String
The first four bytes of the XID as upper-case ByteWords.
Sourcepub fn bytemoji_identifier(&self, prefix: Option<&str>) -> String
pub fn bytemoji_identifier(&self, prefix: Option<&str>) -> String
The first four bytes of the XID as Bytemoji.
Trait Implementations§
Source§impl CBORTagged for Reference
impl CBORTagged for Reference
The CBOR tags assocated with this type. If more than one tag is present,
they are considered equivalent for reading, but only the first one is
used for writing.
Source§impl CBORTaggedDecodable for Reference
impl CBORTaggedDecodable for Reference
Source§fn from_untagged_cbor(cbor: CBOR) -> Result<Self>
fn from_untagged_cbor(cbor: CBOR) -> Result<Self>
Creates an instance of this type by decoding it from untagged CBOR.
Source§fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
Creates an instance of this type by decoding it from tagged CBOR.
Source§impl CBORTaggedEncodable for Reference
impl CBORTaggedEncodable for Reference
Source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Returns the untagged CBOR encoding of this instance.
Source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Returns the tagged CBOR encoding of this instance.
Source§impl Ord for Reference
impl Ord for Reference
Source§impl PartialOrd for Reference
impl PartialOrd for Reference
Source§impl ReferenceProvider for Reference
Implement the ReferenceProvider trait for Reference.
impl ReferenceProvider for Reference
Implement the ReferenceProvider trait for Reference.
Yes, this creates a Reference to a Reference.
fn reference(&self) -> Reference
Source§fn ref_data_short(&self) -> [u8; 4]
fn ref_data_short(&self) -> [u8; 4]
The first four bytes of the reference
Source§fn ref_hex_short(&self) -> String
fn ref_hex_short(&self) -> String
The first four bytes of the reference as a hexadecimal string.
impl Eq for Reference
impl StructuralPartialEq for Reference
Auto Trait Implementations§
impl Freeze for Reference
impl RefUnwindSafe for Reference
impl Send for Reference
impl Sync for Reference
impl Unpin for Reference
impl UnwindSafe for Reference
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> CBOREncodable for T
impl<T> CBOREncodable for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)