Trait vm_superio::Trigger

source ·
pub trait Trigger {
    type E: Debug;

    // Required method
    fn trigger(&self) -> Result<(), Self::E>;
}
Expand description

Abstraction for a simple, push-button like interrupt mechanism. This helps in abstracting away how events/interrupts are generated when working with the emulated devices.

The user has to provide a Trigger object to the device’s constructor when initializing that device. The generic type T: Trigger is used in the device’s structure definition to mark the fact that the events notification mechanism is done via the Trigger interface. An example of how to implement the Trigger interface for an eventfd wrapper can be found in the Example section from Serial. The EventFd is wrapped in the EventFdTrigger newtype because Rust doesn’t allow implementing an external trait on external types. To get around this restriction, the newtype pattern can be used. More details about this, here.

Required Associated Types§

source

type E: Debug

Underlying type for the potential error conditions returned by Self::trigger.

Required Methods§

source

fn trigger(&self) -> Result<(), Self::E>

Trigger an event.

Implementors§