Trait Logger

Source
pub trait Logger<I> {
    type Error;

    // Required method
    fn log(&mut self, item: I) -> Result<(), Self::Error>;

    // Provided methods
    fn by_ref(&mut self) -> &mut Self { ... }
    fn chain<L>(self, other: L) -> Chain<Self, L>
       where Self: Sized { ... }
    fn filter<F>(self, f: F) -> Filter<Self, F>
       where Self: Sized,
             F: FnMut(&I) -> bool { ... }
    fn map<F, B>(self, f: F) -> Map<Self, F, B>
       where Self: Sized { ... }
    fn safe<E>(self) -> Safe<Self, E>
       where Self: Sized { ... }
}
Expand description

A logger is a routine that takes input and has side-effects.

See the documentation for the contralog crate for a general overview of loggers.

Required Associated Types§

Required Methods§

Source

fn log(&mut self, item: I) -> Result<(), Self::Error>

Provided Methods§

Source

fn by_ref(&mut self) -> &mut Self

Create a “by reference” adaptor for this logger.

Source

fn chain<L>(self, other: L) -> Chain<Self, L>
where Self: Sized,

Combine two loggers, creating a new logger that logs each input to both loggers.

Source

fn filter<F>(self, f: F) -> Filter<Self, F>
where Self: Sized, F: FnMut(&I) -> bool,

Apply a function to each input and pass it to the logger only if the function returns true for it.

Source

fn map<F, B>(self, f: F) -> Map<Self, F, B>
where Self: Sized,

Apply a function to each input before passing it to the logger.

Source

fn safe<E>(self) -> Safe<Self, E>
where Self: Sized,

Return a logger that silently drops errors reported by this logger.

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.

Implementations on Foreign Types§

Source§

impl<'a, I, L> Logger<I> for &'a mut L
where L: Logger<I>,

Source§

type Error = <L as Logger<I>>::Error

Source§

fn log(&mut self, item: I) -> Result<(), Self::Error>

Implementors§

Source§

impl<C, I> Logger<I> for Extender<C, I>
where C: Extend<I>,

Source§

impl<I, E> Logger<I> for Empty<I, E>

Source§

type Error = E

Source§

impl<I, L, E> Logger<I> for Safe<L, E>
where L: Logger<I>,

Source§

type Error = E

Source§

impl<I, L, F> Logger<I> for Filter<L, F>
where L: Logger<I>, F: FnMut(&I) -> bool,

Source§

type Error = <L as Logger<I>>::Error

Source§

impl<I, L, F, B> Logger<B> for Map<L, F, B>
where L: Logger<I>, F: FnMut(B) -> I,

Source§

type Error = <L as Logger<I>>::Error

Source§

impl<I, L, M> Logger<I> for Chain<L, M>
where L: Logger<I>, M: Logger<I, Error = L::Error>, I: Clone,

Source§

type Error = <L as Logger<I>>::Error