Skip to main content

Emitter

Trait Emitter 

Source
pub trait Emitter {
    // Required methods
    fn emit<E>(&self, evt: E)
       where E: ToEvent;
    fn blocking_flush(&self, timeout: Duration) -> bool;

    // Provided methods
    fn and_to<U>(self, other: U) -> And<Self, U>
       where Self: Sized { ... }
    fn wrap_emitter<W>(self, wrapping: W) -> Wrap<Self, W>
       where W: Wrapping,
             Self: Sized { ... }
}
Expand description

An asynchronous destination for diagnostic data.

Once Events are emitted through Emitter::emit, a call to Emitter::blocking_flush must be made to ensure they’re fully processed. This should be done once before the emitter is disposed, but may be more frequent for auditing.

Required Methods§

Source

fn emit<E>(&self, evt: E)
where E: ToEvent,

Emit an Event.

Source

fn blocking_flush(&self, timeout: Duration) -> bool

Block for up to timeout, waiting for all diagnostic data emitted up to this point to be fully processed.

This method returns true if the flush completed, and false if it timed out.

If an emitter doesn’t need to flush, this method should immediately return true. If an emitted doesn’t support flushing, this method should immediately return false.

Provided Methods§

Source

fn and_to<U>(self, other: U) -> And<Self, U>
where Self: Sized,

Emit events to both self and other.

Source

fn wrap_emitter<W>(self, wrapping: W) -> Wrap<Self, W>
where W: Wrapping, Self: Sized,

Wrap the emitter, transforming or filtering Events before it receives them.

Flushing defers to the wrapped emitter.

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 Emitter for fn(Event<'_, &dyn ErasedProps>)

Source§

fn emit<E>(&self, evt: E)
where E: ToEvent,

Source§

fn blocking_flush(&self, _: Duration) -> bool

Source§

impl<'a, T> Emitter for &'a T
where T: Emitter + ?Sized,

Source§

fn emit<E>(&self, evt: E)
where E: ToEvent,

Source§

fn blocking_flush(&self, timeout: Duration) -> bool

Source§

impl<'a, T> Emitter for Box<T>
where T: Emitter + 'a + ?Sized,

Available on crate feature alloc only.
Source§

fn emit<E>(&self, evt: E)
where E: ToEvent,

Source§

fn blocking_flush(&self, timeout: Duration) -> bool

Source§

impl<'a, T> Emitter for Arc<T>
where T: Emitter + 'a + ?Sized,

Available on crate feature alloc only.
Source§

fn emit<E>(&self, evt: E)
where E: ToEvent,

Source§

fn blocking_flush(&self, timeout: Duration) -> bool

Source§

impl<T> Emitter for Option<T>
where T: Emitter,

Source§

fn emit<E>(&self, evt: E)
where E: ToEvent,

Source§

fn blocking_flush(&self, timeout: Duration) -> bool

Implementors§

Source§

impl Emitter for Empty

Source§

impl<'a> Emitter for dyn ErasedEmitter + 'a

Source§

impl<'a> Emitter for dyn ErasedEmitter + Sync + Send + 'a

Source§

impl<E, W> Emitter for Wrap<E, W>
where E: Emitter, W: Wrapping,

Source§

impl<F> Emitter for FromFn<F>
where F: Fn(Event<'_, &dyn ErasedProps>),

Source§

impl<T> Emitter for AssertInternal<T>
where T: Emitter,

Source§

impl<T, U> Emitter for And<T, U>
where T: Emitter, U: Emitter,

Source§

impl<TEmitter, TFilter, TCtxt, TClock, TRng> Emitter for Runtime<TEmitter, TFilter, TCtxt, TClock, TRng>
where TEmitter: Emitter, TFilter: Filter, TCtxt: Ctxt, TClock: Clock, TRng: Rng,