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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/interrupt/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

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!


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


/// Trigger an event.
fn trigger(&self) -> Result<(), Self::E>;
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use std::cmp::{Ord, Ordering, PartialOrd};

pub mod device_manager;
pub mod interrupt;
pub mod resources;

// IO Size.
Expand Down