Skip to main content

Observer

Trait Observer 

Source
pub trait Observer {
    const ENABLED: bool = true;

    // Provided method
    fn observe(&mut self, event: Event) { ... }
}
Expand description

Receives Events while an algorithm runs.

Implemented for () (ignores everything; Observer::ENABLED is false, so the algorithms skip all event bookkeeping), for &mut O, and for closures through observer_fn.

Provided Associated Constants§

Source

const ENABLED: bool = true

Whether the algorithms should produce events at all; false only for ().

Provided Methods§

Source

fn observe(&mut self, event: Event)

Receives one event.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Observer for ()

Source§

const ENABLED: bool = false

Source§

impl<O: Observer + ?Sized> Observer for &mut O

Source§

const ENABLED: bool = O::ENABLED

Source§

fn observe(&mut self, event: Event)

Implementors§