1#![cfg_attr(not(feature = "std"), no_std)]
9
10pub mod mutex_impls;
11pub mod notifier;
12pub mod notifier_impls;
13pub mod os_impls;
14pub mod prelude;
15
16pub use embedded_hal;
17pub use fugit;
18pub use mutex_impls::{FakeRawMutex, Mutex};
19pub use mutex_traits;
20pub use mutex_traits::{ConstInit, RawMutex};
21pub use notifier_impls::{AtomicNotifier, FakeNotifier};
22pub use os_impls::{FakeOs, StdOs};
23pub use timeout_trait::{self, *};
24
25use crate::prelude::*;
26
27#[cfg(feature = "alloc")]
28extern crate alloc;
29
30pub trait OsInterface: Send + Sync {
54 type RawMutex: ConstInit + RawMutex;
55 type NotifyBuilder: NotifyBuilder;
56 type Timeout: TimeoutNs;
57
58 fn yield_thread();
59 fn delay() -> impl DelayNs;
60
61 #[inline]
62 fn mutex<T>(d: T) -> Mutex<Self, T> {
63 Mutex::<Self, T>::new(d)
64 }
65
66 #[inline]
67 fn notifier_isr() -> (impl NotifierIsr, impl NotifyWaiter) {
68 Self::NotifyBuilder::build_isr()
69 }
70
71 #[inline]
72 fn notifier() -> (impl Notifier, impl NotifyWaiter) {
73 Self::NotifyBuilder::build()
74 }
75}