async_weighted_semaphore/
errors.rs1use std::fmt;
2use std::fmt::Display;
3use std::error::Error;
4#[allow(unused_imports)] use crate::Semaphore;
6
7#[derive(Debug, Eq, Ord, PartialOrd, PartialEq, Clone, Copy, Hash, Default)]
10pub struct PoisonError;
11
12impl Error for PoisonError {}
13
14impl Display for PoisonError {
15 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> fmt::Result {
16 Display::fmt("the semaphore has been poisoned", f)
17 }
18}
19
20#[derive(Debug, Eq, Ord, PartialOrd, PartialEq, Clone, Copy, Hash)]
23pub enum TryAcquireError {
24 WouldBlock,
27 Poisoned,
29}
30
31impl Error for TryAcquireError {}
32
33impl Display for TryAcquireError {
34 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
35 match self {
36 TryAcquireError::WouldBlock => Display::fmt("the call to acquire would have blocked", f),
37 TryAcquireError::Poisoned => Display::fmt(&PoisonError, f),
38 }
39 }
40}
41
42impl From<PoisonError> for TryAcquireError {
43 fn from(_: PoisonError) -> Self {
44 TryAcquireError::Poisoned
45 }
46}