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
impl ContentAddress
Sourcepub const fn zero() -> Self
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.
Sourcepub const fn as_u128(&self) -> u128
pub const fn as_u128(&self) -> u128
Returns the underlying 128-bit content hash.
Examples found in repository?
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}Sourcepub const fn from_u128(raw: u128) -> Self
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.
Sourcepub const fn from_u64_fingerprint(fingerprint: u64) -> Self
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
impl Clone for ContentAddress
Source§fn clone(&self) -> ContentAddress
fn clone(&self) -> ContentAddress
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentAddress
impl Debug for ContentAddress
Source§impl Default for ContentAddress
impl Default for ContentAddress
Source§impl Hash for ContentAddress
impl Hash for ContentAddress
Source§impl PartialEq for ContentAddress
impl PartialEq for ContentAddress
Source§fn eq(&self, other: &ContentAddress) -> bool
fn eq(&self, other: &ContentAddress) -> bool
self and other values to be equal, and is used by ==.