Struct RngReader
pub struct RngReader<R: TryRng>(pub R);
Adapter to support std::io::Read over a TryRng
Examples
use std::{io, io::Read};
use std::fs::File;
use rand::{rngs::SysRng, RngReader};
io::copy(
&mut RngReader(SysRng).take(100),
&mut File::create("/tmp/random.bytes").unwrap()
).unwrap();
Fields
0: R
Trait Implementations
impl<R: TryRng> Debug for RngReader<R>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<R: TryRng> Read for RngReader<R>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Auto Trait Implementations
impl<R> Freeze for RngReader<R>
where
R: Freeze,
impl<R> RefUnwindSafe for RngReader<R>
where
R: RefUnwindSafe,
impl<R> Send for RngReader<R>
where
R: Send,
impl<R> Sync for RngReader<R>
where
R: Sync,
impl<R> Unpin for RngReader<R>
where
R: Unpin,
impl<R> UnsafeUnpin for RngReader<R>
where
R: UnsafeUnpin,
impl<R> UnwindSafe for RngReader<R>
where
R: UnwindSafe,
Blanket Implementations
impl<T> Any for RngReader<R>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for RngReader<R>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for RngReader<R>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for RngReader<R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for RngReader<R>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for RngReader<R>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for RngReader<R>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>