Observer

Trait Observer 

Source
pub trait Observer<'i, T: ?Sized>: DerefMut<Target = T> {
    // Required methods
    fn observe(value: &'i mut T) -> Self;
    fn collect<A: Adapter>(this: Self) -> Result<Option<Mutation<A>>, A::Error>
       where T: Serialize;
}
Expand description

A trait for observer types that wrap and track mutations to values.

Observers provide transparent access to the underlying value while recording any mutations that occur.

Required Methods§

Source

fn observe(value: &'i mut T) -> Self

Creates a new observer for the given value.

§Arguments
  • value - value to observe
Source

fn collect<A: Adapter>(this: Self) -> Result<Option<Mutation<A>>, A::Error>
where T: Serialize,

Collects all recorded mutations using the specified adapter.

§Type Parameters
  • A - adapter to use for serialization
§Returns
  • None if no mutations were recorded,
  • otherwise a Mutation containing all mutations that occurred.
§Errors
  • Returns an error if serialization fails.

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<'i, T> Observer<'i, T> for ShallowObserver<'i, T>