pub struct Factory { /* private fields */ }Expand description
A factory for generating and caching test artifacts.
Factory is cheap to clone; clones share the same cache.
Implementations§
Source§impl Factory
impl Factory
Sourcepub fn deterministic(master: Seed) -> Self
pub fn deterministic(master: Seed) -> Self
Create a factory in deterministic mode from a master seed.
Sourcepub fn deterministic_from_str(text: &str) -> Self
pub fn deterministic_from_str(text: &str) -> Self
Create a deterministic factory from plain text.
This hashes the provided string verbatim with BLAKE3. Unlike
Seed::from_env_value, it does not trim whitespace or interpret
hex-shaped strings specially.
Sourcepub fn deterministic_from_env(var: &str) -> Result<Self, Error>
pub fn deterministic_from_env(var: &str) -> Result<Self, Error>
Create a deterministic factory from an environment variable.
The environment variable can contain:
- A 64-character hex string (with optional
0xprefix) - Any other string (hashed to produce a 32-byte seed)
§Errors
Returns an error if the environment variable is not set.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the artifact cache.
Sourcepub fn get_or_init<T, F>(
&self,
domain: ArtifactDomain,
label: &str,
spec_bytes: &[u8],
variant: &str,
init: F,
) -> Arc<T> ⓘ
pub fn get_or_init<T, F>( &self, domain: ArtifactDomain, label: &str, spec_bytes: &[u8], variant: &str, init: F, ) -> Arc<T> ⓘ
Return a cached value by (domain, label, spec, variant) or generate one.
The initializer receives the derived seed for this artifact identity. Callers that need an RNG should instantiate it privately from that seed.