usbdac_core/descriptors/error.rs
1//! Error type for descriptor parsing.
2
3use std::fmt;
4
5/// A class-specific descriptor could not be parsed or failed validation.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum DescriptorError {
8 /// The descriptor is truncated, has the wrong type/subtype, or holds a
9 /// value the UAC specification does not allow. The string says which.
10 Invalid(String),
11}
12
13impl fmt::Display for DescriptorError {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 Self::Invalid(message) => write!(f, "invalid descriptor: {message}"),
17 }
18 }
19}
20
21impl std::error::Error for DescriptorError {}