Skip to main content

usb_stack/
error.rs

1//! USB error types.
2
3/// USB operation result type.
4pub type UsbResult<T> = Result<T, UsbError>;
5
6/// Errors returned by USB stack operations.
7#[derive(Clone, Copy, PartialEq, Eq, Debug)]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[non_exhaustive]
10pub enum UsbError {
11    /// An operation would block — no data available or buffer full.
12    WouldBlock,
13    /// A buffer was too small for the data to read, or provided data exceeds length constraints.
14    BufferOverflow,
15    /// The endpoint address is invalid or was not previously allocated.
16    InvalidEndpoint,
17    /// All endpoints of the requested type have been allocated.
18    EndpointOverflow,
19    /// The packet buffer memory available to the USB controller has been exhausted.
20    EndpointMemoryOverflow,
21    /// Operation is not supported by this bus implementation.
22    Unsupported,
23    /// Operation is not valid in the current state.
24    InvalidState,
25    /// A SETUP packet or descriptor could not be parsed.
26    ParseError,
27}