lambda_channel/
err.rs

1use std::error;
2use std::fmt;
3
4/// An error returned from the [`set_pool_size`] method.
5///
6/// [`set_pool_size`]: super::thread::ThreadPool::set_pool_size
7#[derive(PartialEq, Eq, Clone, Copy)]
8pub enum ThreadPoolError {
9    /// Pool size could not be set because the threads in the thread pool have termianted.
10    ThreadsLost,
11
12    /// Pool size cannot be set to zero.
13    ValueError,
14}
15
16impl fmt::Debug for ThreadPoolError {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            ThreadPoolError::ThreadsLost => "ThreadPoolError::ThreadsLost".fmt(f),
20            ThreadPoolError::ValueError => "ThreadPoolError::ValueError".fmt(f),
21        }
22    }
23}
24
25impl fmt::Display for ThreadPoolError {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        match self {
28            ThreadPoolError::ThreadsLost => "thread pool lost".fmt(f),
29            ThreadPoolError::ValueError => "cannot set thread pool size to 0".fmt(f),
30        }
31    }
32}
33
34impl error::Error for ThreadPoolError {}