pub struct FakeCryptoRng<R = XorShiftRng>(/* private fields */);Expand description
A wrapper which implements Rng and CryptoRng for any Rng.
This is used to satisfy RngContext’s requirement that the
associated Rng type implements CryptoRng.
§Security
This is obviously insecure. Don’t use it except in testing!
Implementations§
Source§impl FakeCryptoRng<XorShiftRng>
impl FakeCryptoRng<XorShiftRng>
Sourcepub fn new_xorshift(seed: u128) -> FakeCryptoRng<XorShiftRng>
pub fn new_xorshift(seed: u128) -> FakeCryptoRng<XorShiftRng>
Creates a new FakeCryptoRng<XorShiftRng> from a seed.
Sourcepub fn deep_clone(&self) -> Self
pub fn deep_clone(&self) -> Self
Returns a deep clone of this RNG, copying the current RNG state.
Sourcepub fn with_fake_rngs<F: Fn(Self)>(iterations: u128, f: F)
pub fn with_fake_rngs<F: Fn(Self)>(iterations: u128, f: F)
Creates iterations fake RNGs.
with_fake_rngs will create iterations different
FakeCryptoRngs and call the function f for each one of them.
This function can be used for tests that weed out weirdness that can happen with certain random number sequences.
Trait Implementations§
Source§impl<R: Clone> Clone for FakeCryptoRng<R>
impl<R: Clone> Clone for FakeCryptoRng<R>
Source§fn clone(&self) -> FakeCryptoRng<R>
fn clone(&self) -> FakeCryptoRng<R>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<R: Debug> Debug for FakeCryptoRng<R>
impl<R: Debug> Debug for FakeCryptoRng<R>
Source§impl Default for FakeCryptoRng<XorShiftRng>
impl Default for FakeCryptoRng<XorShiftRng>
Source§fn default() -> FakeCryptoRng<XorShiftRng>
fn default() -> FakeCryptoRng<XorShiftRng>
Returns the “default value” for a type. Read more
Source§impl<R: Rng> RngContext for FakeCryptoRng<R>
impl<R: Rng> RngContext for FakeCryptoRng<R>
Source§impl<R: SeedableRng> SeedableRng for FakeCryptoRng<R>
impl<R: SeedableRng> SeedableRng for FakeCryptoRng<R>
Source§type Seed = <R as SeedableRng>::Seed
type Seed = <R as SeedableRng>::Seed
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N] for some N). Read more§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64 seed. Read more§fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
Create a new PRNG seeded from an infallible
Rng. Read moreimpl<R: Rng> TryCryptoRng for FakeCryptoRng<R>
Source§impl<R: Rng> TryRng for FakeCryptoRng<R>
impl<R: Rng> TryRng for FakeCryptoRng<R>
Source§fn try_next_u32(&mut self) -> Result<u32, Self::Error>
fn try_next_u32(&mut self) -> Result<u32, Self::Error>
Return the next random
u32.Source§fn try_next_u64(&mut self) -> Result<u64, Self::Error>
fn try_next_u64(&mut self) -> Result<u64, Self::Error>
Return the next random
u64.Auto Trait Implementations§
impl<R> Freeze for FakeCryptoRng<R>
impl<R> RefUnwindSafe for FakeCryptoRng<R>
impl<R> Send for FakeCryptoRng<R>where
R: Send,
impl<R> Sync for FakeCryptoRng<R>where
R: Send,
impl<R> Unpin for FakeCryptoRng<R>
impl<R> UnsafeUnpin for FakeCryptoRng<R>
impl<R> UnwindSafe for FakeCryptoRng<R>
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
Mutably borrows from an owned value. Read more
Source§impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R> CryptoRng for R
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
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> ⓘ
Converts
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> ⓘ
Converts
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 moreimpl<B, A> LockBefore<B> for Awhere
B: LockAfter<A>,
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<CC, BC, Meta> RecvFrameContext<Meta, BC> for CCwhere
Meta: ReceivableFrameMeta<CC, BC>,
impl<CC, BC, Meta> RecvFrameContext<Meta, BC> for CCwhere
Meta: ReceivableFrameMeta<CC, BC>,
§impl<R> Rng for R
impl<R> Rng for R
impl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for Rwhere
R: Rng + ?Sized,
impl<R> RngExt for Rwhere
R: Rng + ?Sized,
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
Source§impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CCwhere
Meta: SendableFrameMeta<CC, BC>,
impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CCwhere
Meta: SendableFrameMeta<CC, BC>,
Source§fn send_frame<S>(
&mut self,
bindings_ctx: &mut BC,
metadata: Meta,
frame: S,
) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
Send a frame. Read more
Source§impl<BC, S, Meta, DeviceId> SendableFrameMeta<FakeCoreCtx<S, Meta, DeviceId>, BC> for Meta
impl<BC, S, Meta, DeviceId> SendableFrameMeta<FakeCoreCtx<S, Meta, DeviceId>, BC> for Meta
Source§fn send_meta<SS>(
self,
core_ctx: &mut FakeCoreCtx<S, Meta, DeviceId>,
bindings_ctx: &mut BC,
frame: SS,
) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, SS>>
fn send_meta<SS>( self, core_ctx: &mut FakeCoreCtx<S, Meta, DeviceId>, bindings_ctx: &mut BC, frame: SS, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, SS>>
Sends this frame metadata to the provided contexts.
Source§impl<Meta, BC> SendableFrameMeta<FakeFrameCtx<Meta>, BC> for Meta
impl<Meta, BC> SendableFrameMeta<FakeFrameCtx<Meta>, BC> for Meta
Source§fn send_meta<S>(
self,
core_ctx: &mut FakeFrameCtx<Meta>,
_bindings_ctx: &mut BC,
frame: S,
) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
fn send_meta<S>( self, core_ctx: &mut FakeFrameCtx<Meta>, _bindings_ctx: &mut BC, frame: S, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
Sends this frame metadata to the provided contexts.
Source§impl<Id, CC, BC> TimerHandler<BC, Id> for CCwhere
BC: TimerBindingsTypes,
Id: HandleableTimer<CC, BC>,
impl<Id, CC, BC> TimerHandler<BC, Id> for CCwhere
BC: TimerBindingsTypes,
Id: HandleableTimer<CC, BC>,
Source§fn handle_timer(
&mut self,
bindings_ctx: &mut BC,
dispatch: Id,
timer: <BC as TimerBindingsTypes>::UniqueTimerId,
)
fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )
Handle a timer firing. Read more