Skip to content

Commit 720322d

Browse files
committed
add Trigger trait
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]>
1 parent e60409e commit 720322d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/interrupt/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
3+
4+
use std::result::Result;
5+
6+
/// Abstraction for a simple, push-button like interrupt mechanism.
7+
pub trait Trigger {
8+
/// Underlying type for the potential error conditions returned by `Self::trigger`.
9+
type E;
10+
11+
/// Trigger an event.
12+
fn trigger(&self) -> Result<(), Self::E>;
13+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use std::cmp::{Ord, Ordering, PartialOrd};
77

88
pub mod device_manager;
9+
pub mod interrupt;
910
pub mod resources;
1011

1112
// IO Size.

0 commit comments

Comments
 (0)