pub struct DrawSource { /* private fields */ }Expand description
The random source of TData::new_with_draws,
TData::save_with_draws and TData::migrate_with_draws: the
operating system’s CSPRNG, or, as a testing hook, recorded draws (sized
by draw_plan) replayed in order.
The first failure is kept and every later draw is zero-filled, so the
caller discards whatever was built; DrawSource::finish reports it.
Debug prints draw counts only, never draw bytes, and replayed bytes are
overwritten when the source is dropped.
Implementations§
Source§impl DrawSource
impl DrawSource
Sourcepub fn new(draws: Option<Vec<Vec<u8>>>) -> Self
pub fn new(draws: Option<Vec<Vec<u8>>>) -> Self
The replay of draws when given, else the operating system’s CSPRNG:
the optional draws argument of the bindings.
Sourcepub fn is_replay(&self) -> bool
pub fn is_replay(&self) -> bool
Whether the draws are a replay rather than the operating system’s CSPRNG.
Sourcepub fn fill(&mut self, buf: &mut [u8])
pub fn fill(&mut self, buf: &mut [u8])
Fills buf with the next draw; after a failure, and on the failing
draw, buf is zero-filled instead.
Sourcepub fn finish(self) -> Result<()>
pub fn finish(self) -> Result<()>
The first failure, else a replay whose draws were not all used.
§Errors
Error::Iowhen the operating system’s CSPRNG failed.Error::InvalidInputwithwhat"draws"when the replay did not match what was drawn;reasonis one ofdraw {i} has {n} bytes, but {m} were drawn,draw {i} of {m} bytes was not given ({n} draws given)and{k} of {n} draws were left unused, the texts the bindings show afterdraws:.
Trait Implementations§
Source§impl Debug for DrawSource
impl Debug for DrawSource
Source§impl Drop for DrawSource
impl Drop for DrawSource
Auto Trait Implementations§
impl !RefUnwindSafe for DrawSource
impl !UnwindSafe for DrawSource
impl Freeze for DrawSource
impl Send for DrawSource
impl Sync for DrawSource
impl Unpin for DrawSource
impl UnsafeUnpin for DrawSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more