pub trait HostClass<'d, A: UsbHostAllocator<'d>>: Sized {
type Info: Copy;
const NAME: &'static str;
// Required methods
fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<Self::Info>;
async fn open(
alloc: &A,
cfg: &[u8],
info: Self::Info,
enum_info: &EnumerationInfo,
) -> Result<Self, ClassError>;
// Provided method
fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool { ... }
}Expand description
A host class driver that can be opened from an enumerated device.
The trait is intentionally not dyn-compatible: open is async
and generic over the pipe allocator. Use static dispatch; a feature-gated
AnyClass enum is a possible future extension for dynamic binding.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<Self::Info>
fn probe(enum_info: &EnumerationInfo, cfg: &[u8]) -> Option<Self::Info>
Find the class in an enumerated device. Returns None when the class is
not present. This must not allocate pipes or issue control requests.
cfg is the full configuration descriptor returned by the device and
enum_info carries the device descriptor and bus routing information.
Sourceasync fn open(
alloc: &A,
cfg: &[u8],
info: Self::Info,
enum_info: &EnumerationInfo,
) -> Result<Self, ClassError>
async fn open( alloc: &A, cfg: &[u8], info: Self::Info, enum_info: &EnumerationInfo, ) -> Result<Self, ClassError>
Allocate pipes and perform any class-specific setup.
Provided Methods§
Sourcefn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
fn is_present(enum_info: &EnumerationInfo, cfg: &[u8]) -> bool
Convenience wrapper around probe.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".