pub trait RandomBytes: Send + Sync {
// Required method
fn fill(&self, dest: &mut [u8]) -> Result<(), RandomError>;
}Expand description
The CSPRNG ApiKeys draws key material from. Injected like every
environment effect (ADR 0002) — core carries no entropy source, and
the deployment (or a test) supplies its own. An app crate declaring
getrandom (the workspace-wide leaf pattern) writes:
ⓘ
struct OsRandom;
impl cratefield_core::RandomBytes for OsRandom {
fn fill(&self, dest: &mut [u8]) -> Result<(), RandomError> {
getrandom::fill(dest).map_err(|err| RandomError(err.to_string()))
}
}Required Methods§
Sourcefn fill(&self, dest: &mut [u8]) -> Result<(), RandomError>
fn fill(&self, dest: &mut [u8]) -> Result<(), RandomError>
Fills dest with cryptographically random bytes.
§Errors
RandomError when the platform entropy source fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".