product_os_semaphore/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#![cfg_attr(any(feature = "nightly", doc), feature(negative_impls))]
#![deny(clippy::all)]
#![warn(clippy::pedantic)]

//! `semaphorus` add a [`Semaphore`] type that behaves like a `RwLock`
#![no_std]
extern crate no_std_compat as std;

use std::prelude::v1::*;

pub mod raw;

#[cfg(feature = "wrapper")]
pub mod wrapper;

#[cfg(feature = "wrapper")]
pub use wrapper::*;

#[derive(Clone, Debug)]
#[non_exhaustive]
pub enum SemaphoreError {
    /// The semaphore was already at the maximum amount of references
    AtMaxCount,
}

impl core::fmt::Display for SemaphoreError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            SemaphoreError::AtMaxCount => write!(f, "Already at maximum count!"),
        }
    }
}

#[cfg(feature = "std")]
impl core_error::Error for SemaphoreError {}