Expand description

This library is intended to be used by tools, such as cli’s, which have multiple user interface options, through which they can communicate, while also having various separate commands (or flows) which require each to carefully specify their own output formatting.

The library consists of three primary building blocks, and a default implementation on top of these building blocks.

The three building blocks are:

  • EventHandler: The event handler receives an event (our message type) as input, and decides what to do with this message. Examples include a json-lines handler which prints events to to stderr, a progress bar, a faked handler which collects events for which may be asserted on in software tests, or a handler which sends websocket messages for each event.

  • Reporter: Used to communicate messages to a user.

  • EventListener: Receives the messages, send by a reporter and runs the EventHandler where appropriate.

On top of these building blocks, a channel based implementation is provided which runs the EventHandler in a separate thread. To use this implementation, consult the docs for the ChannelReporter, and the ChannelEventListener.

Structs

A listener which uses a channel to receive messages of type Event, and uses a thread to run the event handler (in ChannelEventListener::run_handler).

A FinishProcessing implementation for the ChannelEventListener. Used to wait for the EventHandler ran by the listener to finish processing events.

A specialized type of reporter which uses a channel to transmit messages.

A receiver, used by ChannelReporter and ChannelEventListener.

A sender, used by ChannelReporter and ChannelEventListener.

Enums

Traits

This can be anything, for example a progress bar, a fake reporter which collects events for testing, a service which sends the events over HTTP, or maybe even a MultiHandler which consists of a Vec<Box<dyn EventHandler>> and executes multiple handlers under the hood.

A listener, which listens to events from a Reporter, and can act upon these events by using an EventHandler.

Provides a way for to wait for EventListener instances to let their EventHandler instances finish up on processing their received events.

A reporter (a type of transmitter) which sends events (the message to be transmitted) to a listener (a type of receiver).

Functions

A channel over which events are sent, from the ChannelReporter to the ChannelEventListener.