Skip to main content

FuzzTarget

Trait FuzzTarget 

Source
pub trait FuzzTarget {
    type Input: Arbitrary<'static>;

    // Required method
    fn fuzz_once(&mut self, input: Self::Input) -> FuzzResult;
}
Expand description

Trait for implementing fuzz targets

Implementors define an Input type that can be generated arbitrarily and a fuzz_once method that tests the code with that input.

Required Associated Types§

Source

type Input: Arbitrary<'static>

Input type for fuzzing - must implement arbitrary::Arbitrary so the fuzzer can generate random instances

Required Methods§

Source

fn fuzz_once(&mut self, input: Self::Input) -> FuzzResult

Execute one fuzz iteration with the given input

This method should:

  • Test the target code with the input
  • Return FuzzResult::Ok if processing succeeds
  • Return FuzzResult::Invalid if input is malformed (expected)
  • Return FuzzResult::Bug if an unexpected error occurs

The method should catch panics and convert them to FuzzResult::Bug.

Implementors§