Mutator

Struct Mutator 

Source
pub struct Mutator<R: Rng> {
    pub rng: R,
    /* private fields */
}
Expand description

Object which provides helper routines for mutating data structures and RNG management.

Fields§

§rng: R

Implementations§

Source§

impl<R: Rng> Mutator<R>

Source

pub fn new(rng: R) -> Mutator<R>

Source

pub fn get_corpus_state(&self) -> CorpusFuzzingState

Source

pub fn set_corpus_state(&mut self, state: CorpusFuzzingState)

Source

pub fn gen<T>(&mut self) -> T
where T: NewFuzzed + 'static,

Generates a random choice of the given type

Source

pub fn mutate<T>(&mut self, num: &mut T)
where T: BitXor<Output = T> + Add<Output = T> + Sub<Output = T> + NumCast + Bounded + Copy + WrappingAdd<Output = T> + WrappingSub<Output = T> + DangerousNumber<T> + Debug,

Mutates a number after randomly selecting a mutation strategy (see [MutatorOperation] for a list of strategies) If a min/max is specified then a new number in this range is chosen instead of performing a bit/arithmetic mutation

Source

pub fn gen_range<T, B1>(&mut self, min: B1, max: B1) -> T

Generates a number in the range from [min, max) (note: non-inclusive). Panics if min >= max.

Source

pub fn gen_weighted_range<T, B1>( &mut self, min: B1, max: B1, weighted: Weighted, ) -> T
where T: SampleUniform + Display + NumCast, B1: SampleBorrow<T> + Display + Debug + Add<Output = B1> + Mul<Output = B1> + NumCast + Sub<Output = B1> + PartialEq + PartialOrd + Copy + Div<Output = B1>,

Generates a number weighted to one end of the interval

Source

pub fn should_early_bail_mutation(&self) -> bool

Helper function for quitting the recursive mutation early if the target field has already been mutated.

Source

pub fn gen_chance(&mut self, chance_percentage: f64) -> bool

Returns a boolean value indicating whether or not the chance event occurred

Source

pub fn random_flags(&mut self)

Client code should call this to signal to the mutator that a new fuzzer iteration is beginning and that the mutator should reset internal state.

Source

pub fn rng_mut(&mut self) -> &mut R

Trait Implementations§

Source§

impl<R: Debug + Rng> Debug for Mutator<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Mutator<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Mutator<R>
where R: RefUnwindSafe,

§

impl<R> Send for Mutator<R>
where R: Send,

§

impl<R> Sync for Mutator<R>
where R: Sync,

§

impl<R> Unpin for Mutator<R>
where R: Unpin,

§

impl<R> UnwindSafe for Mutator<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Fixup for T

Source§

default fn fixup<R>(&mut self, _mutator: &mut Mutator<R>)
where R: Rng,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> VariableSizeObject for T