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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SendErrorNoWait<T> {
    Full(T),
    Closed(T),
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SendError<T> {
    Closed(T),
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RecvErrorNoWait {
    Empty,
    Closed,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RecvError {
    Closed,
}

impl<T> SendErrorNoWait<T> {
    pub fn full(value: T) -> Self {
        Self::Full(value)
    }
    pub fn closed(value: T) -> Self {
        Self::Closed(value)
    }

    pub fn is_full(&self) -> bool {
        matches!(self, Self::Full { .. })
    }
    pub fn is_closed(&self) -> bool {
        matches!(self, Self::Closed { .. })
    }
}

impl RecvErrorNoWait {
    pub fn empty() -> Self {
        Self::Empty
    }
    pub fn closed() -> Self {
        Self::Closed
    }

    pub fn is_empty(&self) -> bool {
        matches!(self, Self::Empty { .. })
    }
    pub fn is_closed(&self) -> bool {
        matches!(self, Self::Closed { .. })
    }
}

impl<T> SendError<T> {
    pub fn closed(value: T) -> Self {
        Self::Closed(value)
    }

    pub fn is_closed(&self) -> bool {
        matches!(self, Self::Closed { .. })
    }
}

impl RecvError {
    pub fn closed() -> Self {
        Self::Closed
    }

    pub fn is_closed(&self) -> bool {
        matches!(self, Self::Closed { .. })
    }
}