pub struct PatternFingerprint(/* private fields */);Expand description
Pattern fingerprint type — re-exported from sdivi-patterns for WASM embedders.
A keyed blake3 digest representing the structural shape of a pattern.
Fingerprints are computed from the node_kind of a [sdivi_parsing::feature_record::PatternHint],
producing a stable, content-independent shape identifier. Two pattern instances
with the same node_kind produce the same PatternFingerprint.
Serialized as a 64-character lowercase hex string for JSON key compatibility.
§Examples
use sdivi_patterns::fingerprint::fingerprint_node_kind;
let fp1 = fingerprint_node_kind("try_expression");
let fp2 = fingerprint_node_kind("try_expression");
let fp3 = fingerprint_node_kind("match_expression");
assert_eq!(fp1, fp2);
assert_ne!(fp1, fp3);
assert_eq!(fp1.to_hex().len(), 64);Implementations§
Source§impl PatternFingerprint
impl PatternFingerprint
Sourcepub fn from_bytes(bytes: [u8; 32]) -> PatternFingerprint
pub fn from_bytes(bytes: [u8; 32]) -> PatternFingerprint
Constructs a PatternFingerprint from raw digest bytes.
Sourcepub fn from_hex(hex: &str) -> Option<PatternFingerprint>
pub fn from_hex(hex: &str) -> Option<PatternFingerprint>
Parses a PatternFingerprint from a 64-character lowercase hex string.
Returns None if the string is not exactly 64 hex characters.
§Examples
use sdivi_patterns::fingerprint::{fingerprint_node_kind, PatternFingerprint};
let fp = fingerprint_node_kind("try_expression");
let hex = fp.to_hex();
let parsed = PatternFingerprint::from_hex(&hex).unwrap();
assert_eq!(fp, parsed);Trait Implementations§
Source§impl Clone for PatternFingerprint
impl Clone for PatternFingerprint
Source§fn clone(&self) -> PatternFingerprint
fn clone(&self) -> PatternFingerprint
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PatternFingerprint
impl Debug for PatternFingerprint
Source§impl<'de> Deserialize<'de> for PatternFingerprint
impl<'de> Deserialize<'de> for PatternFingerprint
Source§fn deserialize<D>(
d: D,
) -> Result<PatternFingerprint, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
d: D,
) -> Result<PatternFingerprint, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for PatternFingerprint
impl Hash for PatternFingerprint
Source§impl Ord for PatternFingerprint
impl Ord for PatternFingerprint
Source§fn cmp(&self, other: &PatternFingerprint) -> Ordering
fn cmp(&self, other: &PatternFingerprint) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PatternFingerprint
impl PartialEq for PatternFingerprint
Source§fn eq(&self, other: &PatternFingerprint) -> bool
fn eq(&self, other: &PatternFingerprint) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for PatternFingerprint
impl PartialOrd for PatternFingerprint
Source§impl Serialize for PatternFingerprint
impl Serialize for PatternFingerprint
Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for PatternFingerprint
impl Eq for PatternFingerprint
impl StructuralPartialEq for PatternFingerprint
Auto Trait Implementations§
impl Freeze for PatternFingerprint
impl RefUnwindSafe for PatternFingerprint
impl Send for PatternFingerprint
impl Sync for PatternFingerprint
impl Unpin for PatternFingerprint
impl UnsafeUnpin for PatternFingerprint
impl UnwindSafe for PatternFingerprint
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.