Skip to main content

SerialEvents

Trait SerialEvents 

Source
pub trait SerialEvents {
    // Required methods
    fn buffer_read(&self);
    fn out_byte(&self);
    fn tx_lost_byte(&self);
    fn in_buffer_empty(&self);
}
Expand description

Defines a series of callbacks that are invoked in response to the occurrence of specific events as part of the serial emulation logic (for example, when the driver reads data). The methods below can be implemented by a backend that keeps track of such events by incrementing metrics, logging messages, or any other action.

We’re using a trait to avoid constraining the concrete characteristics of the backend in any way, enabling zero-cost abstractions and use case-specific implementations.

Required Methods§

Source

fn buffer_read(&self)

The driver reads data from the input buffer.

Source

fn out_byte(&self)

The driver successfully wrote one byte to serial output.

Source

fn tx_lost_byte(&self)

An error occurred while writing a byte to serial output resulting in a lost byte.

Source

fn in_buffer_empty(&self)

This event can be used by the consumer to re-enable events coming from the serial input.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<EV: SerialEvents> SerialEvents for Arc<EV>

Implementors§