pub struct Observers<I> { /* private fields */ }
Expand description
Container for observers.
This type also implements Observe
and therefore can be used like a single observer.
Each observer has an ObserverMode
attached which indicates when the observer will be
called.
Implementations§
source§impl<I> Observers<I>
impl<I> Observers<I>
sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new empty Observers
instance.
Example
use argmin::core::observers::Observers;
use argmin::core::IterState;
let observers: Observers<IterState<Vec<f64>, (), (), (), f64>> = Observers::new();
sourcepub fn push<OBS: Observe<I> + 'static>(
&mut self,
observer: OBS,
mode: ObserverMode
) -> &mut Self
pub fn push<OBS: Observe<I> + 'static>( &mut self, observer: OBS, mode: ObserverMode ) -> &mut Self
Add another observer with a corresponding ObserverMode
.
Example
use argmin::core::observers::{Observers, ObserverMode};
use argmin::core::observers::SlogLogger;
use argmin::core::IterState;
let mut observers: Observers<IterState<Vec<f64>, (), (), (), f64>> = Observers::new();
let logger = SlogLogger::term();
observers.push(logger, ObserverMode::Always);
Trait Implementations§
source§impl<I: State> Observe<I> for Observers<I>
impl<I: State> Observe<I> for Observers<I>
Implementing Observe
for Observers
allows to use it like a single observer. In its
implementation it will loop over all stored observers, checks if the conditions for observing
are met and calls the actual observers if required.
Auto Trait Implementations§
impl<I> RefUnwindSafe for Observers<I>
impl<I> !Send for Observers<I>
impl<I> !Sync for Observers<I>
impl<I> Unpin for Observers<I>
impl<I> UnwindSafe for Observers<I>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.