Skip to main content

CallbackSink

Struct CallbackSink 

Source
pub struct CallbackSink { /* private fields */ }
Expand description

Hands every record line to a callback. A panic in the callback is caught, counted and disables the sink, so it never fails the run. Input: lines. Output: calls to the callback.

Implementations§

Source§

impl CallbackSink

Source

pub fn new(callback: impl Fn(&str) + Send + Sync + 'static) -> CallbackSink

Returns a sink that calls callback with each line. Input: the callback. Output: the sink.

Source

pub fn panics(&self) -> u64

Returns how many times the callback panicked. Input: none.

Source

pub fn is_disabled(&self) -> bool

Returns whether a panic disabled the sink. Input: none.

Trait Implementations§

Source§

impl TraceSink for CallbackSink

Source§

fn write(&self, line: &str)

Takes one record line. Errors are counted by the sink, not returned.
Source§

fn flush(&self)

Pushes buffered lines to their destination. The default does nothing. Trace points made during a flush are suppressed, as during a write.

Auto Trait Implementations§

§

impl !Freeze for CallbackSink

§

impl !RefUnwindSafe for CallbackSink

§

impl !UnwindSafe for CallbackSink

§

impl Forget for CallbackSink

§

impl Move for CallbackSink

§

impl Send for CallbackSink
where BoxRaw<dyn Fn(&str) + Sync + Send>: Send, Atomic<bool>: Send, Atomic<u64>: Send,

§

impl Sync for CallbackSink
where BoxRaw<dyn Fn(&str) + Sync + Send>: Sync, Atomic<bool>: Sync, Atomic<u64>: Sync,

§

impl Unpin for CallbackSink
where Box<dyn Fn(&str) + Sync + Send>: Unpin, Align1<u8>: Unpin, Align8<u64>: Unpin,

§

impl UnsafeUnpin for CallbackSink
where *const dyn Fn(&str) + Sync + Send is !null: UnsafeUnpin, PhantomData<dyn Fn(&str) + Sync + Send>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, Align8<u64>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.