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