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
destentirely with random data.
Provided Methods
fn unwrap_err(self: Self) -> UnwrapErr<Self> where Self: SizedWrap RNG with the
UnwrapErrwrapper.fn read_adapter(self: &mut Self) -> RngReadAdapter<'_, Self> where Self: SizedConvert an
RngCoreto aRngReadAdapter.
Implementors
impl<R> TryRngCore for BlockRng64<R>impl<R> TryRngCore for UnwrapErr<R>impl<R: RngCore> TryRngCore for Rimpl<R> TryRngCore for BlockRng<R>impl TryRngCore for OsRng