[][src]Struct lain::mutator::Mutator

pub struct Mutator<R: Rng> {
    pub rng: R,
    // some fields omitted
}

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

Fields

rng: R

Methods

impl<R: Rng> Mutator<R>[src]

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

pub fn set_mode(&mut self, mode: MutatorMode)[src]

pub fn mode(&self) -> MutatorMode[src]

pub fn get_corpus_state(&self) -> CorpusFuzzingState[src]

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

pub fn gen<T: 'static>(&mut self) -> T where
    T: NewFuzzed
[src]

Generates a random choice of the given type

pub fn mutate_from_mutation_mode<T>(&mut self, mn: &mut T) where
    T: BitXor<Output = T> + Add<Output = T> + Sub<Output = T> + WrappingAdd<Output = T> + WrappingSub<Output = T> + NumCast + Bounded + Copy + DangerousNumber<T> + Display
[src]

TODO: Change function name. Mutates mn while taking into consideration the current mutator mode.

pub fn next_mode<T: Bounded + NumCast + DangerousNumber<T>>(&mut self)[src]

Manages the mutator mode state machine.

This will basically:

  • Swap between the different MutatorModes. This will transition from walking bit flips to dangerous numbers, to havoc mode.
  • For each mode, determine if there are any any other substates to exhaust (e.g. more bits to flip, more dangerous numbers to select), and update the state accordingly for the next iteration. If no other substates exist, the hard MutatorMode state will move to the next enum variant. Before reaching the MutatorMode::Havoc state, each subsequent mode will check if the last field has been mutated yet. If not, the state will reset to MutatorMode::WalkingBitFlip and adjust the current member index being fuzzed.
  • Once all members have been fuzzed in all MutatorModes, the mode is set to MutatorMode::Havoc.

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>, 
[src]

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

pub fn gen_range<T, B1>(&mut self, min: B1, max: B1) -> T where
    T: SampleUniform + Display,
    B1: SampleBorrow<T> + Display + Add + Mul + NumCast + Sub + PartialEq + PartialOrd
[src]

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

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>, 
[src]

Generates a number weighted to one end of the interval

pub fn gen_chance_to_mutate_field(&mut self, chance_percentage: f32) -> bool[src]

Generates the chance to mutate a field. This will always return true if the current mode is MutatorMode::Havoc.

pub fn should_early_bail_mutation(&self) -> bool[src]

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

pub fn gen_chance(&mut self, chance_percentage: f32) -> bool[src]

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

pub fn should_fixup(&mut self) -> bool[src]

Returns a boolean indicating whether or not post mutation steps should be taken

pub fn begin_new_iteration(&mut self)[src]

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.

pub fn begin_new_corpus(&mut self)[src]

Resets the corpus state and current mutation mode.

Trait Implementations

impl<R: Debug + Rng> Debug for Mutator<R>[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T> Fixup for T[src]

impl<T> VariableSizeObject for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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