Skip to main content

HashProvider

Trait HashProvider 

Source
pub trait HashProvider: Send + Sync {
    // Required methods
    fn hash(&self, content: &[u8]) -> String;
    fn prefix(&self) -> &'static str;

    // Provided method
    fn hash_bytes(&self, content: &[u8]) -> [u8; 32] { ... }
}
Expand description

Trait for pluggable content-hash algorithms.

Any type implementing this trait can serve as CLM’s content hash function. The trait is intentionally minimal: hash returns the raw hex digest, and prefix returns the algorithm tag used in prefixed storage format.

Required Methods§

Source

fn hash(&self, content: &[u8]) -> String

Compute the raw hex digest of content.

Source

fn prefix(&self) -> &'static str

Algorithm prefix (e.g. "blake3:", "sha256:").

Provided Methods§

Source

fn hash_bytes(&self, content: &[u8]) -> [u8; 32]

Compute the raw digest as a fixed-size byte array (for Merkle trees, etc.). Default implementation parses the hex digest; providers may override for efficiency.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§