Skip to main content

ContentAddress

Struct ContentAddress 

Source
pub struct ContentAddress { /* private fields */ }
Expand description

v0.2.2 T4.2: sealed content-addressed handle. Wraps a 128-bit identity used for BindingsTable lookups and as a compact identity handle for Grounded values. The underlying u128 is visible via as_u128() for interop. Distinct from ContentFingerprint (the parametric-width fingerprint computed by the substrate Hasher — see T5.C3.d below): ContentAddress is a fixed 16-byte sortable handle, while ContentFingerprint is the full substrate-computed identity that round-trips through verify_trace.

Implementations§

Source§

impl ContentAddress

Source

pub const fn zero() -> Self

The zero content address. Used as the “unset” placeholder in BindingsTable lookups, the default state of an uninitialised Grounded::unit_address, and the initial seed of replay folds.

Source

pub const fn as_u128(&self) -> u128

Returns the underlying 128-bit content hash.

Examples found in repository?
examples/static_bindings_catalog.rs (line 71)
57fn main() {
58    println!("Static BindingsTable with {} entries:", TABLE.entries.len());
59    for entry in TABLE.entries {
60        println!(
61            "  address={:?} bytes={:?}",
62            entry.address,
63            core::str::from_utf8(entry.bytes).expect("surface is utf8")
64        );
65    }
66
67    // Lookup: binary search by address (BindingsTable entries are sorted).
68    let lookup_addr = BINDINGS[1].to_binding_entry().address;
69    let found = TABLE
70        .entries
71        .binary_search_by_key(&lookup_addr.as_u128(), |e| e.address.as_u128())
72        .map(|idx| &TABLE.entries[idx]);
73
74    match found {
75        Ok(entry) => println!(
76            "Lookup found: {:?}",
77            core::str::from_utf8(entry.bytes).unwrap_or("?")
78        ),
79        Err(_) => println!("Lookup miss"),
80    }
81}
Source

pub const fn is_zero(&self) -> bool

Whether this content address is the zero handle.

Source

pub const fn from_u128(raw: u128) -> Self

v0.2.2 T5.C1: public ctor. Promoted from pub(crate) in T5 so downstream tests can construct deterministic ContentAddress values for fixture data without going through the foundation pipeline.

Source

pub const fn from_u64_fingerprint(fingerprint: u64) -> Self

v0.2.2 Phase P.3: construct a ContentAddress from a u64 FNV-1a fingerprint by right-padding the value into the 128-bit address space. Used by Binding::to_binding_entry to bridge the Binding.content_address: u64 carrier to the BindingEntry.address: ContentAddress (u128-backed) shape. The lift is raw = (fingerprint as u128) << 64 — upper 64 bits carry the FNV-1a value; lower 64 bits are zero. Content-deterministic; round-trips via ContentAddress::as_u128() >> 64 back to the original u64.

Trait Implementations§

Source§

impl Clone for ContentAddress

Source§

fn clone(&self) -> ContentAddress

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContentAddress

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Hash for ContentAddress

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ContentAddress

Source§

fn eq(&self, other: &ContentAddress) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ContentAddress

Source§

impl Eq for ContentAddress

Source§

impl StructuralPartialEq for ContentAddress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.