Skip to main content

openraft_rt/watch/
watch_error.rs

1use std::fmt;
2
3/// Error returned by the `WatchSender`.
4#[derive(PartialEq, Eq, Clone, Copy)]
5pub struct SendError<T>(pub T);
6
7impl<T> fmt::Debug for SendError<T> {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9        f.debug_struct("SendError").finish_non_exhaustive()
10    }
11}
12
13impl<T> fmt::Display for SendError<T> {
14    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
15        write!(fmt, "watch channel closed")
16    }
17}
18
19impl<T> std::error::Error for SendError<T> {}
20
21/// Error returned by the `WatchReceiver`.
22#[derive(PartialEq, Eq, Clone, Copy)]
23pub struct RecvError(pub ());
24
25impl fmt::Debug for RecvError {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        f.debug_struct("RecvError").finish_non_exhaustive()
28    }
29}
30
31impl fmt::Display for RecvError {
32    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
33        write!(fmt, "watch channel closed")
34    }
35}
36
37impl std::error::Error for RecvError {}