Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexandruag
Copy link
Collaborator

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 using EventFds to generate events/interrupts for vm-superio devices.

@@ -0,0 +1,10 @@
use std::result::Result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing copyright.

Copy link
Collaborator Author

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]>
@andreeaflorescu
Copy link
Member

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;

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants