Trait MakeWriter

Source
pub trait MakeWriter {
    type Writer: Write;

    // Required method
    fn make_writer(&self) -> Self::Writer;
}
Expand description

A type that can create io::Write instances.

MakeWriter is used by FmtSubscriber to print formatted text representations of Events.

This trait is already implemented for function pointers and immutably-borrowing closures that return an instance of io::Write, such as io::stdout and io::stderr.

Required Associated Types§

Source

type Writer: Write

The concrete io::Write implementation returned by make_writer.

Required Methods§

Source

fn make_writer(&self) -> Self::Writer

Returns an instance of Writer.

§Implementer notes

FmtSubscriber will call this method each time an event is recorded. Ensure any state that must be saved across writes is not lost when the Writer instance is dropped. If creating a io::Write instance is expensive, be sure to cache it when implementing MakeWriter to improve performance.

Implementors§

Source§

impl<F, W> MakeWriter for F
where F: Fn() -> W, W: Write,