pub struct ARID(/* private fields */);Expand description
An “Apparently Random Identifier” (ARID)
An ARID is a cryptographically strong, universally unique identifier with the following properties:
- Non-correlatability: The sequence of bits cannot be correlated with its referent or any other ARID
- Neutral semantics: Contains no inherent type information
- Open generation: Any method of generation is allowed as long as it produces statistically random bits
- Minimum strength: Must be 256 bits (32 bytes) in length
- Cryptographic suitability: Can be used as inputs to cryptographic constructs
Unlike digests/hashes which identify a fixed, immutable state of data, ARIDs can serve as stable identifiers for mutable data structures.
ARIDs should not be confused with or cast to/from other identifier types (like UUIDs), used as nonces, keys, or cryptographic seeds.
As defined in BCR-2022-002.
Implementations§
Source§impl ARID
impl ARID
pub const ARID_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 ARID from a reference to an array of bytes.
Sourcepub fn from_hex(hex: impl AsRef<str>) -> Self
pub fn from_hex(hex: impl AsRef<str>) -> Self
Create a new ARID from the given hexadecimal string.
§Panics
Panics if the string is not exactly 64 hexadecimal digits.
Sourcepub fn short_description(&self) -> String
pub fn short_description(&self) -> String
The first four bytes of the ARID as a hexadecimal string.
Trait Implementations§
Source§impl CBORTagged for ARID
Implements the CBORTagged trait to provide CBOR tag information.
impl CBORTagged for ARID
Implements the CBORTagged trait to provide CBOR tag information.
Source§impl CBORTaggedDecodable for ARID
Implements CBORTaggedDecodable to provide CBOR decoding functionality.
impl CBORTaggedDecodable for ARID
Implements CBORTaggedDecodable to provide CBOR decoding functionality.
Source§fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
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,
Source§impl CBORTaggedEncodable for ARID
Implements CBORTaggedEncodable to provide CBOR encoding functionality.
impl CBORTaggedEncodable for ARID
Implements CBORTaggedEncodable to provide CBOR encoding functionality.
Source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Source§impl<'a> From<&'a ARID> for &'a [u8]
Implements conversion from an ARID reference to a byte slice reference.
impl<'a> From<&'a ARID> for &'a [u8]
Implements conversion from an ARID reference to a byte slice reference.
Source§impl PartialOrd for ARID
Implements PartialOrd to allow ARIDs to be compared and ordered.
impl PartialOrd for ARID
Implements PartialOrd to allow ARIDs to be compared and ordered.
Source§impl TryFrom<CBOR> for ARID
Implements TryFrom<CBOR> for ARID to support conversion from CBOR data.
impl TryFrom<CBOR> for ARID
Implements TryFrom<CBOR> for ARID to support conversion from CBOR data.
impl Copy for ARID
impl Eq for ARID
impl StructuralPartialEq for ARID
Auto Trait Implementations§
impl Freeze for ARID
impl RefUnwindSafe for ARID
impl Send for ARID
impl Sync for ARID
impl Unpin for ARID
impl UnwindSafe for ARID
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
Source§impl<T> CBORDecodable for T
impl<T> CBORDecodable for T
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>,
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>,
self into the result. Upper case
letters are used (e.g. F9B4CA)