pub struct HashConfig {
pub active_algorithm: &'static str,
pub collision_threshold: u32,
pub fallback_order: Vec<&'static str>,
}Expand description
Configuration policy for hash algorithm selection and collision handling.
This struct governs:
- Which algorithm is used for new content (
active_algorithm) - How many collisions trigger an automatic upgrade (
collision_threshold) - The order of fallback algorithms if the active one is compromised
The config is stored in a global OnceLock and can be loaded from a
configuration file or environment variable at startup.
Fields§
§active_algorithm: &'static strAlgorithm prefix for new content (e.g. "blake3:", "sha256:").
collision_threshold: u32Number of collisions before triggering an upgrade.
fallback_order: Vec<&'static str>Ordered list of fallback algorithm prefixes. If the active algorithm is compromised, the first available fallback becomes the new active algorithm.
Implementations§
Source§impl HashConfig
impl HashConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load hash configuration from environment variables.
Checks in order:
CLM_HASH_CONFIG:active_algorithm|collision_threshold|fallback1,fallback2,...Example:blake3:|2|blake3:,sha256:CLM_HASH_ALGO/MCARD_HASH_ALGORITHM: simple string override (e.g.blake3orsha256)
If unset, returns the central BLAKE3 default. Unsupported configured names are preserved;
write operations reject them through raw_hash_bytes_for instead of silently downgrading.
Trait Implementations§
Source§impl Clone for HashConfig
impl Clone for HashConfig
Source§impl Debug for HashConfig
impl Debug for HashConfig
Auto Trait Implementations§
impl Forget for HashConfig
impl Freeze for HashConfig
impl RefUnwindSafe for HashConfig
impl Send for HashConfig
impl Sync for HashConfig
impl Unpin for HashConfig
impl UnsafeUnpin for HashConfig
impl UnwindSafe for HashConfig
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