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. -
EventReporter: Used to communicate messages to a user. -
EventListener: Receives the messages, send by a reporter and runs theEventHandlerwhere 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§
- Channel
Event Listener - A listener which uses a channel to receive messages of type
Event, and uses a thread to run the event handler (inChannelEventListener::run_handler). - Channel
Finalize Handler - A
FinishProcessingimplementation for theChannelEventListener. Used to wait for theEventHandlerran by thelistenerto finish processing events. - Channel
Reporter - A specialized type of reporter which uses a channel to transmit messages.
- Event
Receiver - A receiver, used by
ChannelReporterandChannelEventListener. - Event
Send Error - Event
Sender - A sender, used by
ChannelReporterandChannelEventListener.
Enums§
Traits§
- Event
Handler - 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
MultiHandlerwhich consists of aVec<Box<dyn EventHandler>>and executes multiple handlers under the hood. - Event
Listener - A listener, which listens to events from a
EventReporter, and can act upon these events by using anEventHandler. - Event
Reporter - A reporter (a type of transmitter) which sends events (the message to be transmitted) to a listener (a type of receiver).
- Finish
Processing - Provides a way for to wait for
EventListenerinstances to let theirEventHandlerinstances finish up on processing their received events.
Functions§
- event_
channel - A channel over which events are sent, from the
ChannelReporterto theChannelEventListener.