ReferenceProvider

Trait ReferenceProvider 

Source
pub trait ReferenceProvider {
    // Required method
    fn reference(&self) -> Reference;

    // Provided methods
    fn ref_hex(&self) -> String { ... }
    fn ref_data_short(&self) -> [u8; 4] { ... }
    fn ref_hex_short(&self) -> String { ... }
    fn ref_bytewords(&self, prefix: Option<&str>) -> String { ... }
    fn ref_bytemoji(&self, prefix: Option<&str>) -> String { ... }
}
Expand description

Implementers of this trait provide a globally unique reference to themselves.

The ReferenceProvider trait is used to create a unique, cryptographic reference to an object. This is particularly useful for distributed systems where objects need to be uniquely identified across networks or storage systems.

The reference is derived from a cryptographic digest of the object’s serialized form, ensuring that the reference uniquely identifies the object’s contents.

Required Methods§

Source

fn reference(&self) -> Reference

Returns a cryptographic reference that uniquely identifies this object.

The reference is derived from a digest of the object’s serialized form, ensuring that it uniquely identifies the object’s contents.

Provided Methods§

Source

fn ref_hex(&self) -> String

Returns the reference data as a hexadecimal string.

This is a convenience method that returns the full 32-byte reference as a 64-character hexadecimal string.

Source

fn ref_data_short(&self) -> [u8; 4]

Returns the first four bytes of the reference.

This is a convenience method for when a shorter, more user-friendly representation is needed, such as for display or comparison purposes.

Source

fn ref_hex_short(&self) -> String

Returns the first four bytes of the reference as a hexadecimal string.

This produces an 8-character string that is useful for display purposes, such as in debug output or logs.

Source

fn ref_bytewords(&self, prefix: Option<&str>) -> String

Returns the first four bytes of the reference as upper-case ByteWords.

ByteWords is a human-readable encoding format that uses common English words to represent binary data, making it easier to communicate verbally or in text.

§Parameters
  • prefix - An optional prefix to add before the ByteWords representation
Source

fn ref_bytemoji(&self, prefix: Option<&str>) -> String

Returns the first four bytes of the reference as Bytemoji.

Bytemoji is an emoji-based encoding that represents binary data using emoji characters, which can be more visually distinctive and memorable.

§Parameters
  • prefix - An optional prefix to add before the Bytemoji representation

Implementors§

Source§

impl ReferenceProvider for PrivateKeys

Source§

impl ReferenceProvider for PublicKeys

Source§

impl ReferenceProvider for Reference

Implement the ReferenceProvider trait for Reference.

Yes, this creates a Reference to a Reference.

Source§

impl ReferenceProvider for XID

Implements ReferenceProvider for XID to generate a Reference from the XID.