smolusb/
error.rs

1//! smolusb Error type
2
3#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4pub enum ErrorKind {
5    Timeout(usize),
6    Overflow(usize),
7}
8
9impl core::fmt::Display for ErrorKind {
10    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
11        core::fmt::Debug::fmt(&self, f)
12    }
13}
14
15#[cfg(feature = "nightly")]
16impl core::error::Error for ErrorKind {
17    #[allow(deprecated)]
18    fn description(&self) -> &str {
19        use ErrorKind::*;
20        match self {
21            Timeout(_) => "Blocking operation timed-out",
22            Overflow(_) => "Read operation overflowed receive buffer",
23        }
24    }
25}