pub trait EventSource: AsRawDescriptor {
    // Required methods
    fn receive_events(&mut self) -> Result<usize>;
    fn available_events_count(&self) -> usize;
    fn pop_available_event(&mut self) -> Option<virtio_input_event>;
    fn send_event(&mut self, vio_evt: &virtio_input_event) -> Result<()>;

    // Provided methods
    fn init(&mut self) -> Result<()> { ... }
    fn finalize(&mut self) -> Result<()> { ... }
}
Expand description

Encapsulates a socket or device node into an abstract event source, providing a common interface. It supports read and write operations to provide and accept events just like an event device node would, except that it handles virtio_input_event instead of input_event structures. It’s necessary to call receive_events() before events are available for read.

Required Methods§

source

fn receive_events(&mut self) -> Result<usize>

Receive events from the source, filters them and stores them in a queue for future consumption by reading from this object. Returns the number of new non filtered events received. This function may block waiting for events to be available.

source

fn available_events_count(&self) -> usize

Returns the number of received events that have not been filtered or consumed yet.

source

fn pop_available_event(&mut self) -> Option<virtio_input_event>

Returns the next available event

source

fn send_event(&mut self, vio_evt: &virtio_input_event) -> Result<()>

Sends a status update event to the source

Provided Methods§

source

fn init(&mut self) -> Result<()>

Perform any necessary initialization before receiving and sending events from/to the source.

source

fn finalize(&mut self) -> Result<()>

Perform any necessary cleanup when the device will no longer be used.

Implementors§