semaphorus/
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
7pub mod raw;
8
9#[cfg(feature = "wrapper")]
10pub mod wrapper;
11
12#[cfg(feature = "wrapper")]
13pub use wrapper::*;
14
15#[derive(Clone, Debug)]
16#[non_exhaustive]
17pub enum SemaphoreError {
18    /// The semaphore was already at the maximum amount of references
19    AtMaxCount,
20}
21
22impl core::fmt::Display for SemaphoreError {
23    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
24        match self {
25            SemaphoreError::AtMaxCount => write!(f, "Already at maximum count!"),
26        }
27    }
28}
29
30#[cfg(feature = "std")]
31impl std::error::Error for SemaphoreError {}