Trait MapObserver

Source
pub trait MapObserver:
    HasLen
    + Named
    + Serialize
    + DeserializeOwned
    + AsRef<Self>
    + AsMut<Self> {
    type Entry: PartialEq + Copy;

    // Required methods
    fn get(&self, idx: usize) -> Self::Entry;
    fn set(&mut self, idx: usize, val: Self::Entry);
    fn usable_count(&self) -> usize;
    fn count_bytes(&self) -> u64;
    fn initial(&self) -> Self::Entry;
    fn reset_map(&mut self) -> Result<(), Error>;
    fn to_vec(&self) -> Vec<Self::Entry>;
    fn how_many_set(&self, indexes: &[usize]) -> usize;
}
Expand description

A MapObserver observes the static map, as oftentimes used for AFL-like coverage information

When referring to this type in a constraint (e.g. O: MapObserver), ensure that you only refer to instances of a second type, e.g. C: AsRef<O> or A: AsMut<O>. Map observer instances are passed around in a way that may be potentially wrapped by e.g. ExplicitTracking as a way to encode metadata into the type. This is an unfortunate additional requirement that we can’t get around without specialization.

See crate::require_index_tracking for an example of how to do so.

TODO: enforce iter() -> AssociatedTypeIter when generic associated types stabilize

Required Associated Types§

Source

type Entry: PartialEq + Copy

Type of each entry in this map

Required Methods§

Source

fn get(&self, idx: usize) -> Self::Entry

Get the value at idx

Source

fn set(&mut self, idx: usize, val: Self::Entry)

Set the value at idx

Source

fn usable_count(&self) -> usize

Get the number of usable entries in the map (all by default)

Source

fn count_bytes(&self) -> u64

Count the set bytes in the map

Source

fn initial(&self) -> Self::Entry

Get the initial value for reset()

Source

fn reset_map(&mut self) -> Result<(), Error>

Reset the map

Source

fn to_vec(&self) -> Vec<Self::Entry>

Get these observer’s contents as Vec

Source

fn how_many_set(&self, indexes: &[usize]) -> usize

Get the number of set entries with the specified indexes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<M> MapObserver for HitcountsIterableMapObserver<M>
where M: MapObserver<Entry = u8>,

Source§

impl<M> MapObserver for HitcountsMapObserver<M>
where M: MapObserver<Entry = u8>,

Source§

impl<T> MapObserver for OwnedMapObserver<T>

Source§

type Entry = T

Source§

impl<T> MapObserver for VariableMapObserver<'_, T>

Source§

type Entry = T

Source§

impl<T, A> MapObserver for RefCellValueObserver<'_, A>

Source§

type Entry = T

Source§

impl<T, const DIFFERENTIAL: bool> MapObserver for MultiMapObserver<'_, T, DIFFERENTIAL>

Source§

type Entry = T

Source§

impl<T, const DIFFERENTIAL: bool> MapObserver for StdMapObserver<'_, T, DIFFERENTIAL>

Source§

type Entry = T

Source§

impl<T, const N: usize> MapObserver for ConstMapObserver<'_, T, N>
where T: PartialEq + Copy + Hash + Serialize + DeserializeOwned + Debug + 'static,

Source§

type Entry = T