product_os_semaphore/
lib.rs

1#![cfg_attr(any(feature = "nightly", doc), feature(negative_impls))]
2#![deny(clippy::all)]
3#![warn(clippy::pedantic)]
4
5//! `semaphorus` add a [`Semaphore`] type that behaves like a `RwLock`
6#![no_std]
7extern crate no_std_compat as std;
8
9use std::prelude::v1::*;
10
11pub mod raw;
12
13#[cfg(feature = "wrapper")]
14pub mod wrapper;
15
16#[cfg(feature = "wrapper")]
17pub use wrapper::*;
18
19#[derive(Clone, Debug)]
20#[non_exhaustive]
21pub enum SemaphoreError {
22    /// The semaphore was already at the maximum amount of references
23    AtMaxCount,
24}
25
26impl core::fmt::Display for SemaphoreError {
27    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
28        match self {
29            SemaphoreError::AtMaxCount => write!(f, "Already at maximum count!"),
30        }
31    }
32}
33
34#[cfg(feature = "std")]
35impl core_error::Error for SemaphoreError {}