@@ -258,17 +258,17 @@ pub mod macros {
258
258
/// As an example, if you are developing the type `MyCustomScheduler<O>` which requires novelty
259
259
/// tracking, use this in your constructor:
260
260
/// ```
261
- /// # use libafl::observers::TrackingHinted;
261
+ /// # use libafl::observers::{MapObserver, TrackingHinted} ;
262
262
/// # use libafl::require_index_tracking;
263
263
/// # use core::marker::PhantomData;
264
264
/// #
265
- /// # struct MyCustomScheduler<O> {
266
- /// # phantom: PhantomData<O >,
265
+ /// # struct MyCustomScheduler<O, A > {
266
+ /// # phantom: PhantomData<(O, A) >,
267
267
/// # }
268
268
/// #
269
- /// impl<O> MyCustomScheduler<O> where O: TrackingHinted {
270
- /// pub fn new() -> Self {
271
- /// require_index_tracking!("MyCustomScheduler", O );
269
+ /// impl<O, A > MyCustomScheduler<O, A > where O: MapObserver, A: AsRef<O> + TrackingHinted {
270
+ /// pub fn new(obs: &A ) -> Self {
271
+ /// require_index_tracking!("MyCustomScheduler", A );
272
272
/// todo!("Construct your type")
273
273
/// }
274
274
/// }
@@ -309,17 +309,17 @@ pub mod macros {
309
309
/// As an example, if you are developing the type `MyCustomScheduler<O>` which requires novelty
310
310
/// tracking, use this in your constructor:
311
311
/// ```
312
- /// # use libafl::observers::TrackingHinted;
312
+ /// # use libafl::observers::{MapObserver, TrackingHinted} ;
313
313
/// # use libafl::require_novelties_tracking;
314
314
/// # use core::marker::PhantomData;
315
315
/// #
316
- /// # struct MyCustomScheduler<O> {
317
- /// # phantom: PhantomData<O >,
316
+ /// # struct MyCustomScheduler<O, A > {
317
+ /// # phantom: PhantomData<(O, A) >,
318
318
/// # }
319
319
/// #
320
- /// impl<O> MyCustomScheduler<O> where O: TrackingHinted {
321
- /// pub fn new() -> Self {
322
- /// require_novelties_tracking!("MyCustomScheduler", O );
320
+ /// impl<O, A > MyCustomScheduler<O, A > where O: MapObserver, A: AsRef<O> + TrackingHinted {
321
+ /// pub fn new(obs: &A ) -> Self {
322
+ /// require_novelties_tracking!("MyCustomScheduler", A );
323
323
/// todo!("Construct your type")
324
324
/// }
325
325
/// }
@@ -357,6 +357,14 @@ pub mod macros {
357
357
358
358
/// A [`MapObserver`] observes the static map, as oftentimes used for AFL-like coverage information
359
359
///
360
+ /// When referring to this type in a constraint (e.g. `O: MapObserver`), ensure that you only refer
361
+ /// to instances of a second type, e.g. `A: AsRef<O>`. Map observer instances are passed around in
362
+ /// a way that may be potentially wrapped by e.g. [`ExplicitTracking`] as a way to encode metadata
363
+ /// into the type. This is an unfortunate additional requirement that we can't get around without
364
+ /// specialization.
365
+ ///
366
+ /// See [`crate::require_index_tracking`] for an example of how to do so.
367
+ ///
360
368
/// TODO: enforce `iter() -> AssociatedTypeIter` when generic associated types stabilize
361
369
pub trait MapObserver :
362
370
HasLen + Named + Serialize + serde:: de:: DeserializeOwned + AsRef < Self >
0 commit comments