pub struct XID(/* private fields */);Expand description
A XID (eXtensible IDentifier).
Implementations§
Source§impl XID
impl XID
pub const XID_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 XID from data.
Returns None if the data is not the correct length.
Sourcepub fn new(genesis_key: &SigningPublicKey) -> Self
pub fn new(genesis_key: &SigningPublicKey) -> Self
Create a new XID from the given public key (the “genesis key”).
The XID is the SHA-256 digest of the CBOR encoding of the public key.
Sourcepub fn validate(&self, key: &SigningPublicKey) -> bool
pub fn validate(&self, key: &SigningPublicKey) -> bool
Validate the XID against the given public key.
Sourcepub fn from_hex(hex: impl AsRef<str>) -> Self
pub fn from_hex(hex: impl AsRef<str>) -> Self
Create a new XID 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 XID as a hexadecimal string.
Sourcepub fn bytewords_identifier(&self, prefix: bool) -> String
pub fn bytewords_identifier(&self, prefix: bool) -> String
The first four bytes of the XID as upper-case ByteWords.
Sourcepub fn bytemoji_identifier(&self, prefix: bool) -> String
pub fn bytemoji_identifier(&self, prefix: bool) -> String
The first four bytes of the XID as Bytemoji.
Sourcepub fn lifehash_fingerprint(&self) -> Digest
pub fn lifehash_fingerprint(&self) -> Digest
The entire CBOR of the XID, run through SHA-256.
Trait Implementations§
Source§impl CBORTagged for XID
impl CBORTagged for XID
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 XID
impl CBORTaggedDecodable for XID
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 XID
impl CBORTaggedEncodable for XID
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 From<&PrivateKeyBase> for XID
impl From<&PrivateKeyBase> for XID
Source§fn from(key: &PrivateKeyBase) -> Self
fn from(key: &PrivateKeyBase) -> Self
Converts to this type from the input type.
Source§impl From<&PublicKeyBase> for XID
impl From<&PublicKeyBase> for XID
Source§fn from(key: &PublicKeyBase) -> Self
fn from(key: &PublicKeyBase) -> Self
Converts to this type from the input type.
Source§impl From<&SigningPrivateKey> for XID
impl From<&SigningPrivateKey> for XID
Source§fn from(key: &SigningPrivateKey) -> Self
fn from(key: &SigningPrivateKey) -> Self
Converts to this type from the input type.
Source§impl From<&SigningPublicKey> for XID
impl From<&SigningPublicKey> for XID
Source§fn from(key: &SigningPublicKey) -> Self
fn from(key: &SigningPublicKey) -> Self
Converts to this type from the input type.
Source§impl Ord for XID
impl Ord for XID
Source§impl PartialOrd for XID
impl PartialOrd for XID
impl Eq for XID
impl StructuralPartialEq for XID
Auto Trait Implementations§
impl Freeze for XID
impl RefUnwindSafe for XID
impl Send for XID
impl Sync for XID
impl Unpin for XID
impl UnwindSafe for XID
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)