pub struct Fingerprint(/* private fields */);Expand description
A per-symbol content fingerprint: the first 16 bytes of a BLAKE3 digest.
Language adapters compute two per symbol (see sealmap-extract’s fingerprint
module): sig_hash over the contract and body_hash over the
implementation. The model only stores, compares, prints and parses them.
Displayed and serialised as blake3-16:<32 hex chars>. 128 bits keeps an
accidental collision out of reach for any realistic number of symbols
while halving the text a full digest would cost in every model and lock.
Fingerprint::default is all zeros and means “not fingerprinted”: a
symbol built by hand with Symbol::new carries it
until a language adapter fills in real values.
use sealmap_model::Fingerprint;
let f = Fingerprint::from_bytes([0xab; 16]);
let text = f.to_string();
assert_eq!(text, format!("blake3-16:{}", "ab".repeat(16)));
assert_eq!(Fingerprint::parse(&text), Some(f));
assert!(Fingerprint::default().is_unset());Implementations§
Source§impl Fingerprint
impl Fingerprint
Sourcepub const fn from_bytes(bytes: [u8; 16]) -> Self
pub const fn from_bytes(bytes: [u8; 16]) -> Self
Wrap 16 digest bytes.
Sourcepub fn from_blake3(hash: &Hash) -> Self
pub fn from_blake3(hash: &Hash) -> Self
Truncate a full BLAKE3 digest.
Sourcepub fn merge(self, other: Self) -> Self
pub fn merge(self, other: Self) -> Self
Fold two fingerprints of the same symbol into one, independent of
their order. Used when #[cfg]-gated twins share an id and are
merged by Codebase::add_symbol: a
change to either twin changes the merged value.
use sealmap_model::Fingerprint;
let (a, b) = (Fingerprint::from_bytes([1; 16]), Fingerprint::from_bytes([2; 16]));
assert_eq!(a.merge(b), b.merge(a));
assert_ne!(a.merge(b), a);