Trait libafl::corpus::Corpus

source ·
pub trait Corpus: UsesInput + Serialize + for<'de> Deserialize<'de> {
Show 22 methods // Required methods fn count(&self) -> usize; fn count_disabled(&self) -> usize; fn count_all(&self) -> usize; fn add( &mut self, testcase: Testcase<Self::Input> ) -> Result<CorpusId, Error>; fn add_disabled( &mut self, testcase: Testcase<Self::Input> ) -> Result<CorpusId, Error>; fn replace( &mut self, idx: CorpusId, testcase: Testcase<Self::Input> ) -> Result<Testcase<Self::Input>, Error>; fn remove(&mut self, id: CorpusId) -> Result<Testcase<Self::Input>, Error>; fn get( &self, id: CorpusId ) -> Result<&RefCell<Testcase<Self::Input>>, Error>; fn get_from_all( &self, id: CorpusId ) -> Result<&RefCell<Testcase<Self::Input>>, Error>; fn current(&self) -> &Option<CorpusId>; fn current_mut(&mut self) -> &mut Option<CorpusId>; fn next(&self, id: CorpusId) -> Option<CorpusId>; fn prev(&self, id: CorpusId) -> Option<CorpusId>; fn first(&self) -> Option<CorpusId>; fn last(&self) -> Option<CorpusId>; fn nth_from_all(&self, nth: usize) -> CorpusId; fn load_input_into( &self, testcase: &mut Testcase<Self::Input> ) -> Result<(), Error>; fn store_input_from( &self, testcase: &Testcase<Self::Input> ) -> Result<(), Error>; // Provided methods fn is_empty(&self) -> bool { ... } fn ids(&self) -> CorpusIdIterator<'_, Self> { ... } fn nth(&self, nth: usize) -> CorpusId { ... } fn cloned_input_for_id(&self, idx: CorpusId) -> Result<Self::Input, Error> { ... }
}
Expand description

Corpus with all current Testcases, or solutions

Required Methods§

source

fn count(&self) -> usize

Returns the number of all enabled entries

source

fn count_disabled(&self) -> usize

Returns the number of all disabled entries

source

fn count_all(&self) -> usize

Returns the number of elements including disabled entries

source

fn add(&mut self, testcase: Testcase<Self::Input>) -> Result<CorpusId, Error>

Add an enabled testcase to the corpus and return its index

source

fn add_disabled( &mut self, testcase: Testcase<Self::Input> ) -> Result<CorpusId, Error>

Add a disabled testcase to the corpus and return its index

source

fn replace( &mut self, idx: CorpusId, testcase: Testcase<Self::Input> ) -> Result<Testcase<Self::Input>, Error>

Replaces the Testcase at the given idx, returning the existing.

source

fn remove(&mut self, id: CorpusId) -> Result<Testcase<Self::Input>, Error>

Removes an entry from the corpus, returning it if it was present.

source

fn get(&self, id: CorpusId) -> Result<&RefCell<Testcase<Self::Input>>, Error>

Get by id; considers only enabled testcases

source

fn get_from_all( &self, id: CorpusId ) -> Result<&RefCell<Testcase<Self::Input>>, Error>

Get by id; considers both enabled and disabled testcases

source

fn current(&self) -> &Option<CorpusId>

Current testcase scheduled

source

fn current_mut(&mut self) -> &mut Option<CorpusId>

Current testcase scheduled (mutable)

source

fn next(&self, id: CorpusId) -> Option<CorpusId>

Get the next corpus id

source

fn prev(&self, id: CorpusId) -> Option<CorpusId>

Get the prev corpus id

source

fn first(&self) -> Option<CorpusId>

Get the first inserted corpus id

source

fn last(&self) -> Option<CorpusId>

Get the last inserted corpus id

source

fn nth_from_all(&self, nth: usize) -> CorpusId

Get the nth corpus id; considers both enabled and disabled testcases

source

fn load_input_into( &self, testcase: &mut Testcase<Self::Input> ) -> Result<(), Error>

Method to load the input for this Testcase from persistent storage, if necessary, and if was not already loaded (== Some(input)). After this call, testcase.input() must always return Some(input).

source

fn store_input_from( &self, testcase: &Testcase<Self::Input> ) -> Result<(), Error>

Method to store the input of this Testcase to persistent storage, if necessary.

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true, if no elements are in this corpus yet

source

fn ids(&self) -> CorpusIdIterator<'_, Self>

An iterator over very active corpus id

source

fn nth(&self, nth: usize) -> CorpusId

Get the nth corpus id; considers only enabled testcases

source

fn cloned_input_for_id(&self, idx: CorpusId) -> Result<Self::Input, Error>

Loads the Input for a given CorpusId from the Corpus, and returns the clone.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<I> Corpus for CachedOnDiskCorpus<I>
where I: Input,

source§

impl<I> Corpus for InMemoryCorpus<I>
where I: Input,

source§

impl<I> Corpus for InMemoryOnDiskCorpus<I>
where I: Input,

source§

impl<I> Corpus for NopCorpus<I>
where I: Input,

source§

impl<I> Corpus for OnDiskCorpus<I>
where I: Input,