-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple Trigger trait for generating events #29
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,10 @@ | |||
use std::result::Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing copyright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
This is a simple interface which models an object that can generate a single event. Each attempt to trigger the event may return an error, which is defined by an associated type. Signed-off-by: Alexandru Agache <[email protected]>
17e0796
to
720322d
Compare
LGTM. This is the right step towards abstracting away the hypervisor from the emulation layer as well (i.e. looks like what we would need to fix: rust-vmm/vm-superio#7). |
/// Abstraction for a simple, push-button like interrupt mechanism. | ||
pub trait Trigger { | ||
/// Underlying type for the potential error conditions returned by `Self::trigger`. | ||
type E; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better and more typical to use Error
for the generic error type (this is used https://doc.rust-lang.org/std/convert/trait.TryFrom.html for instance).
This PR introduces the simple
Trigger
trait. I've started looking at the pending interrupt proposals and it seems this is a fundamental piece of functionality that we want to include anyway. Also, it can already help with abstracting away things such as usingEventFd
s to generate events/interrupts forvm-superio
devices.