Trait TryRngCore

trait TryRngCore

A potentially fallible variant of RngCore

This trait is a generalization of RngCore to support potentially- fallible IO-based generators such as OsRng.

All implementations of RngCore automatically support this TryRngCore trait, using [Infallible][core::convert::Infallible] as the associated Error type.

An implementation of this trait may be made compatible with code requiring an RngCore through TryRngCore::unwrap_err. The resulting RNG will panic in case the underlying fallible RNG yields an error.

Associated Types

type Error: TraitBound { trait_: Path { path: "fmt::Debug", id: Id(99), args: None }, generic_params: [], modifier: None } + TraitBound { trait_: Path { path: "fmt::Display", id: Id(223), args: None }, generic_params: [], modifier: None }

The type returned in the event of a RNG error.

Required Methods

fn try_next_u32(self: &mut Self) -> Result<u32, <Self as >::Error>

Return the next random u32.

fn try_next_u64(self: &mut Self) -> Result<u64, <Self as >::Error>

Return the next random u64.

fn try_fill_bytes(self: &mut Self, dst: &mut [u8]) -> Result<(), <Self as >::Error>

Fill dest entirely with random data.

Provided Methods

fn unwrap_err(self: Self) -> UnwrapErr<Self>
where
    Self: Sized

Wrap RNG with the UnwrapErr wrapper.

fn read_adapter(self: &mut Self) -> RngReadAdapter<'_, Self>
where
    Self: Sized

Convert an RngCore to a RngReadAdapter.

Implementors