Trait bolero::Driver

source ·
pub trait Driver: Sized {
Show 44 methods // Required methods fn depth(&self) -> usize; fn set_depth(&mut self, depth: usize); fn max_depth(&self) -> usize; fn gen_variant( &mut self, variants: usize, base_case: usize, ) -> Option<usize>; fn gen_u8(&mut self, min: Bound<&u8>, max: Bound<&u8>) -> Option<u8>; fn gen_i8(&mut self, min: Bound<&i8>, max: Bound<&i8>) -> Option<i8>; fn gen_u16(&mut self, min: Bound<&u16>, max: Bound<&u16>) -> Option<u16>; fn gen_i16(&mut self, min: Bound<&i16>, max: Bound<&i16>) -> Option<i16>; fn gen_u32(&mut self, min: Bound<&u32>, max: Bound<&u32>) -> Option<u32>; fn gen_i32(&mut self, min: Bound<&i32>, max: Bound<&i32>) -> Option<i32>; fn gen_u64(&mut self, min: Bound<&u64>, max: Bound<&u64>) -> Option<u64>; fn gen_i64(&mut self, min: Bound<&i64>, max: Bound<&i64>) -> Option<i64>; fn gen_u128(&mut self, min: Bound<&u128>, max: Bound<&u128>) -> Option<u128>; fn gen_i128(&mut self, min: Bound<&i128>, max: Bound<&i128>) -> Option<i128>; fn gen_usize( &mut self, min: Bound<&usize>, max: Bound<&usize>, ) -> Option<usize>; fn gen_isize( &mut self, min: Bound<&isize>, max: Bound<&isize>, ) -> Option<isize>; fn gen_f32(&mut self, min: Bound<&f32>, max: Bound<&f32>) -> Option<f32>; fn gen_f64(&mut self, min: Bound<&f64>, max: Bound<&f64>) -> Option<f64>; fn gen_char(&mut self, min: Bound<&char>, max: Bound<&char>) -> Option<char>; fn gen_bool(&mut self, probability: Option<f32>) -> Option<bool>; fn gen_from_bytes<Hint, Gen, T>( &mut self, hint: Hint, gen: Gen, ) -> Option<T> where Hint: FnOnce() -> (usize, Option<usize>), Gen: FnMut(&[u8]) -> Option<(usize, T)>; // Provided methods fn gen<T>(&mut self) -> Option<T> where T: TypeGenerator { ... } fn depth_guard<F, R>(&mut self, f: F) -> Option<R> where F: FnOnce(&mut Self) -> Option<R> { ... } fn enter_product<Output, F, Ret>(&mut self, f: F) -> Option<Ret> where Output: 'static, F: FnMut(&mut Self) -> Option<Ret> { ... } fn enter_sum<Output, F, Ret>( &mut self, element_names: Option<&'static [&'static str]>, elements: usize, base_case: usize, f: F, ) -> Option<Ret> where Output: 'static, F: FnMut(&mut Self, usize) -> Option<Ret> { ... } fn enter_list<Output, F, Len, Ret>( &mut self, lens: &Len, f: F, ) -> Option<Ret> where Output: 'static, F: FnMut(&mut Self, usize) -> Option<Ret>, Len: ValueGenerator<Output = usize> { ... } fn enter_combinator<Output, F, Ret>(&mut self, f: F) -> Option<Ret> where Output: 'static, F: FnMut(&mut Self) -> Option<Ret> { ... } fn gen_u8_constant(&mut self, value: u8) -> Option<u8> { ... } fn gen_i8_constant(&mut self, value: i8) -> Option<i8> { ... } fn gen_u16_constant(&mut self, value: u16) -> Option<u16> { ... } fn gen_i16_constant(&mut self, value: i16) -> Option<i16> { ... } fn gen_u32_constant(&mut self, value: u32) -> Option<u32> { ... } fn gen_i32_constant(&mut self, value: i32) -> Option<i32> { ... } fn gen_u64_constant(&mut self, value: u64) -> Option<u64> { ... } fn gen_i64_constant(&mut self, value: i64) -> Option<i64> { ... } fn gen_u128_constant(&mut self, value: u128) -> Option<u128> { ... } fn gen_i128_constant(&mut self, value: i128) -> Option<i128> { ... } fn gen_usize_constant(&mut self, value: usize) -> Option<usize> { ... } fn gen_isize_constant(&mut self, value: isize) -> Option<isize> { ... } fn gen_f32_constant(&mut self, value: f32) -> Option<f32> { ... } fn gen_f64_constant(&mut self, value: f64) -> Option<f64> { ... } fn gen_char_constant(&mut self, value: char) -> Option<char> { ... } fn cache_put<T>(&mut self, value: T) where T: 'static { ... } fn cache_get<T>(&mut self) -> Option<T> where T: 'static { ... }
}
Expand description

Trait for driving the generation of a value

In a test engine, this is typically backed by a byte slice, but other drivers can be used instead, e.g. an RNG implementation.

Required Methods§

source

fn depth(&self) -> usize

source

fn set_depth(&mut self, depth: usize)

source

fn max_depth(&self) -> usize

source

fn gen_variant(&mut self, variants: usize, base_case: usize) -> Option<usize>

source

fn gen_u8(&mut self, min: Bound<&u8>, max: Bound<&u8>) -> Option<u8>

source

fn gen_i8(&mut self, min: Bound<&i8>, max: Bound<&i8>) -> Option<i8>

source

fn gen_u16(&mut self, min: Bound<&u16>, max: Bound<&u16>) -> Option<u16>

source

fn gen_i16(&mut self, min: Bound<&i16>, max: Bound<&i16>) -> Option<i16>

source

fn gen_u32(&mut self, min: Bound<&u32>, max: Bound<&u32>) -> Option<u32>

source

fn gen_i32(&mut self, min: Bound<&i32>, max: Bound<&i32>) -> Option<i32>

source

fn gen_u64(&mut self, min: Bound<&u64>, max: Bound<&u64>) -> Option<u64>

source

fn gen_i64(&mut self, min: Bound<&i64>, max: Bound<&i64>) -> Option<i64>

source

fn gen_u128(&mut self, min: Bound<&u128>, max: Bound<&u128>) -> Option<u128>

source

fn gen_i128(&mut self, min: Bound<&i128>, max: Bound<&i128>) -> Option<i128>

source

fn gen_usize(&mut self, min: Bound<&usize>, max: Bound<&usize>) -> Option<usize>

source

fn gen_isize(&mut self, min: Bound<&isize>, max: Bound<&isize>) -> Option<isize>

source

fn gen_f32(&mut self, min: Bound<&f32>, max: Bound<&f32>) -> Option<f32>

source

fn gen_f64(&mut self, min: Bound<&f64>, max: Bound<&f64>) -> Option<f64>

source

fn gen_char(&mut self, min: Bound<&char>, max: Bound<&char>) -> Option<char>

source

fn gen_bool(&mut self, probability: Option<f32>) -> Option<bool>

source

fn gen_from_bytes<Hint, Gen, T>(&mut self, hint: Hint, gen: Gen) -> Option<T>
where Hint: FnOnce() -> (usize, Option<usize>), Gen: FnMut(&[u8]) -> Option<(usize, T)>,

Generate a value from bytes off this generator

len is the size of the slice that should be passed to gen. The range’s minimal size is the minimal amount of bytes needed to properly generate an input. The range’s maximal value should be so that every T can be generated by gen from a slice of this length.

gen is the function that actually does the generation. It takes as input the byte slice, and returns either None (if not enough bytes were provided to build a T, this can happen even with a slice of maximum length but should happen as rarely as possible), or a Some value if it could generate a T. In this case, it also returns the number of bytes that were actually consumed from the slice.

Note that gen may be called multiple times with increasing slice lengths, eg. if the driver is in forced mode.

Provided Methods§

source

fn gen<T>(&mut self) -> Option<T>
where T: TypeGenerator,

Generate a value with type T

source

fn depth_guard<F, R>(&mut self, f: F) -> Option<R>
where F: FnOnce(&mut Self) -> Option<R>,

source

fn enter_product<Output, F, Ret>(&mut self, f: F) -> Option<Ret>
where Output: 'static, F: FnMut(&mut Self) -> Option<Ret>,

source

fn enter_sum<Output, F, Ret>( &mut self, element_names: Option<&'static [&'static str]>, elements: usize, base_case: usize, f: F, ) -> Option<Ret>
where Output: 'static, F: FnMut(&mut Self, usize) -> Option<Ret>,

source

fn enter_list<Output, F, Len, Ret>(&mut self, lens: &Len, f: F) -> Option<Ret>
where Output: 'static, F: FnMut(&mut Self, usize) -> Option<Ret>, Len: ValueGenerator<Output = usize>,

source

fn enter_combinator<Output, F, Ret>(&mut self, f: F) -> Option<Ret>
where Output: 'static, F: FnMut(&mut Self) -> Option<Ret>,

source

fn gen_u8_constant(&mut self, value: u8) -> Option<u8>

source

fn gen_i8_constant(&mut self, value: i8) -> Option<i8>

source

fn gen_u16_constant(&mut self, value: u16) -> Option<u16>

source

fn gen_i16_constant(&mut self, value: i16) -> Option<i16>

source

fn gen_u32_constant(&mut self, value: u32) -> Option<u32>

source

fn gen_i32_constant(&mut self, value: i32) -> Option<i32>

source

fn gen_u64_constant(&mut self, value: u64) -> Option<u64>

source

fn gen_i64_constant(&mut self, value: i64) -> Option<i64>

source

fn gen_u128_constant(&mut self, value: u128) -> Option<u128>

source

fn gen_i128_constant(&mut self, value: i128) -> Option<i128>

source

fn gen_usize_constant(&mut self, value: usize) -> Option<usize>

source

fn gen_isize_constant(&mut self, value: isize) -> Option<isize>

source

fn gen_f32_constant(&mut self, value: f32) -> Option<f32>

source

fn gen_f64_constant(&mut self, value: f64) -> Option<f64>

source

fn gen_char_constant(&mut self, value: char) -> Option<char>

source

fn cache_put<T>(&mut self, value: T)
where T: 'static,

source

fn cache_get<T>(&mut self) -> Option<T>
where T: 'static,

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a> Driver for ByteSliceDriver<'a>

source§

impl<'a, I> Driver for Driver<'a, I>
where I: Driver,

source§

impl<R> Driver for Rng<R>
where R: RngCore,