From 720322d0946f0095c1d6f01b5616ef0502f46643 Mon Sep 17 00:00:00 2001 From: Alexandru Agache Date: Wed, 23 Sep 2020 23:19:18 +0300 Subject: [PATCH] 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 --- src/interrupt/mod.rs | 13 +++++++++++++ src/lib.rs | 1 + 2 files changed, 14 insertions(+) create mode 100644 src/interrupt/mod.rs diff --git a/src/interrupt/mod.rs b/src/interrupt/mod.rs new file mode 100644 index 0000000..82b770a --- /dev/null +++ b/src/interrupt/mod.rs @@ -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>; +} diff --git a/src/lib.rs b/src/lib.rs index dc09ddb..235e4da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ use std::cmp::{Ord, Ordering, PartialOrd}; pub mod device_manager; +pub mod interrupt; pub mod resources; // IO Size.