parcoll/
lock_free_errors.rs

1/// Represents the possible errors that can occur when lock-free popping a value from a queue.
2pub enum LockFreePopErr {
3    /// The queue was empty.
4    Empty,
5    /// The queue should wait for another operation to finish.
6    ShouldWait,
7}
8
9impl std::fmt::Debug for LockFreePopErr {
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        match self {
12            Self::Empty => write!(f, "empty"),
13            Self::ShouldWait => write!(f, "should wait"),
14        }
15    }
16}
17
18/// Represents the possible errors that can occur when lock-free pushing a value into a queue.
19pub enum LockFreePushErr<T> {
20    /// The queue was full.
21    Full(T),
22    /// The queue should wait for another operation to finish.
23    ShouldWait(T),
24}
25
26impl<T> std::fmt::Debug for LockFreePushErr<T> {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        match self {
29            Self::Full(_) => write!(f, "full"),
30            Self::ShouldWait(_) => write!(f, "should wait"),
31        }
32    }
33}
34
35/// Represents the possible errors that can occur when lock-free pushing many values into a queue.
36pub enum LockFreePushManyErr {
37    /// The queue was full.
38    NotEnoughSpace,
39    /// The queue should wait for another operation to finish.
40    ShouldWait,
41}
42
43impl std::fmt::Debug for LockFreePushManyErr {
44    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
45        match self {
46            Self::NotEnoughSpace => write!(f, "not enough space"),
47            Self::ShouldWait => write!(f, "should wait"),
48        }
49    }
50}