1use alloc::{boxed::Box, string::String};
2
3#[derive(thiserror::Error, Debug)]
4pub enum TransferError {
5 #[error("Stall")]
6 Stall,
7 #[error("Queue full")]
8 QueueFull,
9 #[error("Invalid endpoint")]
10 InvalidEndpoint,
11 #[error("No device")]
12 NoDevice,
13 #[error("Not supported")]
14 NotSupported,
15 #[error("Timeout")]
16 Timeout,
17 #[error("Cancelled")]
18 Cancelled,
19 #[error("Other error: {0}")]
20 Other(#[from] anyhow::Error),
21}
22
23impl From<Box<dyn core::error::Error>> for TransferError {
24 fn from(err: Box<dyn core::error::Error>) -> Self {
25 TransferError::Other(anyhow::anyhow!("{}", err))
26 }
27}
28
29#[derive(thiserror::Error, Debug)]
30pub enum USBError {
31 #[error("Timeout")]
32 Timeout,
33 #[error("No memory available")]
34 NoMemory,
35 #[error("Transfer error: {0}")]
36 TransferError(#[from] TransferError),
37 #[error("Not initialized")]
38 NotInitialized,
39 #[error("Not found")]
40 NotFound,
41 #[error("Invalid parameter")]
42 InvalidParameter,
43 #[error("Slot limit reached")]
44 SlotLimitReached,
45 #[error("Configuration not set")]
46 ConfigurationNotSet,
47 #[error("Not supported")]
48 NotSupported,
49 #[error("Other error: {0}")]
50 Other(#[from] anyhow::Error),
51}
52
53impl From<&str> for USBError {
54 fn from(value: &str) -> Self {
55 USBError::Other(anyhow::anyhow!("{value}"))
56 }
57}
58
59impl From<String> for USBError {
60 fn from(value: String) -> Self {
61 USBError::Other(anyhow::anyhow!(value))
62 }
63}
64
65