reset() method for FeedbackState
This commit is contained in:
parent
d136ee7427
commit
231caf0797
@ -132,9 +132,14 @@ where
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> FeedbackState for MapFeedbackState<T> where
|
impl<T> FeedbackState for MapFeedbackState<T>
|
||||||
T: Integer + Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned
|
where
|
||||||
|
T: Integer + Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
|
fn reset(&mut self) -> Result<(), Error> {
|
||||||
|
self.history_map.iter_mut().for_each(|x| *x = T::default());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Named for MapFeedbackState<T>
|
impl<T> Named for MapFeedbackState<T>
|
||||||
|
@ -96,18 +96,33 @@ where
|
|||||||
|
|
||||||
/// [`FeedbackState`] is the data associated with a [`Feedback`] that must persist as part
|
/// [`FeedbackState`] is the data associated with a [`Feedback`] that must persist as part
|
||||||
/// of the fuzzer State
|
/// of the fuzzer State
|
||||||
pub trait FeedbackState: Named + serde::Serialize + serde::de::DeserializeOwned {}
|
pub trait FeedbackState: Named + serde::Serialize + serde::de::DeserializeOwned {
|
||||||
|
/// Reset the internal state
|
||||||
|
fn reset(&mut self) -> Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A haskell-style tuple of feedback states
|
/// A haskell-style tuple of feedback states
|
||||||
pub trait FeedbackStatesTuple: MatchName + serde::Serialize + serde::de::DeserializeOwned {}
|
pub trait FeedbackStatesTuple: MatchName + serde::Serialize + serde::de::DeserializeOwned {
|
||||||
|
fn reset_all(&mut self) -> Result<(), Error>;
|
||||||
|
}
|
||||||
|
|
||||||
impl FeedbackStatesTuple for () {}
|
impl FeedbackStatesTuple for () {
|
||||||
|
fn reset_all(&mut self) -> Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<Head, Tail> FeedbackStatesTuple for (Head, Tail)
|
impl<Head, Tail> FeedbackStatesTuple for (Head, Tail)
|
||||||
where
|
where
|
||||||
Head: FeedbackState,
|
Head: FeedbackState,
|
||||||
Tail: FeedbackStatesTuple,
|
Tail: FeedbackStatesTuple,
|
||||||
{
|
{
|
||||||
|
fn reset_all(&mut self) -> Result<(), Error> {
|
||||||
|
self.0.reset()?;
|
||||||
|
self.1.reset_all()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CombinedFeedback<A, B, I, S, FL>
|
pub struct CombinedFeedback<A, B, I, S, FL>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user