Skip to content

Commit

Permalink
add Trigger trait
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alexandruag committed Sep 24, 2020
1 parent e60409e commit 720322d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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;

/// 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;

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

0 comments on commit 720322d

Please sign in to comment.