blocking_permit/
errors.rs

1use std::fmt;
2use std::io;
3
4/// Error type returned as output from the
5/// [`BlockingPermitFuture`](crate::BlockingPermitFuture) or
6/// [`Dispatched`](crate::Dispatched) futures if they are canceled.
7///
8/// This only occurs if the associated `Semaphore` is closed or `DispatchPool`
9/// is dropped, respectively.
10#[derive(Debug)]
11pub struct Canceled;
12
13impl fmt::Display for Canceled {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        write!(f, "Waiting for a blocking permit or dispatch was canceled")
16    }
17}
18
19impl std::error::Error for Canceled {}
20
21impl From<Canceled> for io::Error {
22    fn from(me: Canceled) -> io::Error {
23        io::Error::new(io::ErrorKind::Other, me)
24    }
25}