Struct zksync_consensus_utils::EncodeDist
source · pub struct EncodeDist {
pub required_only: bool,
pub decimal_fractions: bool,
}
Expand description
Distribution for testing encodings.
Fields§
§required_only: bool
Generate configs with only required fields.
decimal_fractions: bool
Generate decimal fractions for f64 to avoid rounding errors of decimal encodings.
Implementations§
source§impl EncodeDist
impl EncodeDist
sourcepub fn sample_range(&self, rng: &mut (impl Rng + ?Sized)) -> Range<usize>
pub fn sample_range(&self, rng: &mut (impl Rng + ?Sized)) -> Range<usize>
Returns a small non-empty range if required_only
is false.
Returns an empty range otherwise.
sourcepub fn sample_opt<T>(&self, f: impl FnOnce() -> T) -> Option<T>
pub fn sample_opt<T>(&self, f: impl FnOnce() -> T) -> Option<T>
Returns Some(f())
if required_only
is false.
Returns `None otherwise.
sourcepub fn sample_collect<T: IntoIterator + FromIterator<T::Item>>(
&self,
rng: &mut (impl Rng + ?Sized),
) -> T
pub fn sample_collect<T: IntoIterator + FromIterator<T::Item>>( &self, rng: &mut (impl Rng + ?Sized), ) -> T
Samples a collection of type T.
Trait Implementations§
source§impl Distribution<Credentials> for EncodeDist
impl Distribution<Credentials> for EncodeDist
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Credentials
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Credentials
Generate a random value of
T
, using rng
as the source of randomness.source§fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
Create an iterator that generates random values of
T
, using rng
as
the source of randomness. Read moresource§impl Distribution<Duration> for EncodeDist
impl Distribution<Duration> for EncodeDist
source§impl Distribution<Host> for EncodeDist
impl Distribution<Host> for EncodeDist
source§impl Distribution<NonZero<u32>> for EncodeDist
impl Distribution<NonZero<u32>> for EncodeDist
source§impl<T> Distribution<Option<T>> for EncodeDistwhere
EncodeDist: Distribution<T>,
impl<T> Distribution<Option<T>> for EncodeDistwhere
EncodeDist: Distribution<T>,
source§impl Distribution<PathBuf> for EncodeDist
impl Distribution<PathBuf> for EncodeDist
source§impl Distribution<Rate> for EncodeDist
impl Distribution<Rate> for EncodeDist
source§impl Distribution<SocketAddr> for EncodeDist
impl Distribution<SocketAddr> for EncodeDist
source§impl Distribution<String> for EncodeDist
impl Distribution<String> for EncodeDist
source§impl Distribution<bool> for EncodeDist
impl Distribution<bool> for EncodeDist
source§impl Distribution<f64> for EncodeDist
impl Distribution<f64> for EncodeDist
source§impl Distribution<i16> for EncodeDist
impl Distribution<i16> for EncodeDist
source§impl Distribution<i32> for EncodeDist
impl Distribution<i32> for EncodeDist
source§impl Distribution<i64> for EncodeDist
impl Distribution<i64> for EncodeDist
source§impl Distribution<i8> for EncodeDist
impl Distribution<i8> for EncodeDist
source§impl Distribution<u16> for EncodeDist
impl Distribution<u16> for EncodeDist
source§impl Distribution<u32> for EncodeDist
impl Distribution<u32> for EncodeDist
source§impl Distribution<u64> for EncodeDist
impl Distribution<u64> for EncodeDist
source§impl Distribution<u8> for EncodeDist
impl Distribution<u8> for EncodeDist
source§impl Distribution<usize> for EncodeDist
impl Distribution<usize> for EncodeDist
Auto Trait Implementations§
impl Freeze for EncodeDist
impl RefUnwindSafe for EncodeDist
impl Send for EncodeDist
impl Sync for EncodeDist
impl Unpin for EncodeDist
impl UnwindSafe for EncodeDist
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