pub trait HmacFactoryExt {
// Required method
fn hmac(&self, label: impl AsRef<str>, spec: HmacSpec) -> HmacSecret;
}Expand description
Extension trait to hang HMAC helpers off the core Factory.
Required Methods§
Sourcefn hmac(&self, label: impl AsRef<str>, spec: HmacSpec) -> HmacSecret
fn hmac(&self, label: impl AsRef<str>, spec: HmacSpec) -> HmacSecret
Generate (or retrieve from cache) an HMAC secret fixture.
The label identifies this secret within your test suite.
In deterministic mode, seed + label + spec always produces the same secret.
§Examples
use uselesskey_core::{Factory, Seed};
use uselesskey_hmac::{HmacFactoryExt, HmacSpec};
let seed = Seed::from_env_value("test-seed").unwrap();
let fx = Factory::deterministic(seed);
let secret = fx.hmac("jwt-signing", HmacSpec::hs256());
// Same seed + label + spec = same secret
let secret2 = fx.hmac("jwt-signing", HmacSpec::hs256());
assert_eq!(secret.secret_bytes(), secret2.secret_bytes());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.