embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

HostClass

Trait HostClass 

Source
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§

Source

const NAME: &'static str

Human-readable class name, used for logging.

Required Associated Types§

Source

type Info: Copy

Cheap, owned description of the interface(s) and endpoints to use.

This must not borrow from the configuration descriptor buffer, so that it can outlive the probe call and be passed to open.

Required Methods§

Source

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.

Source

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§

Source

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".

Implementors§

Source§

impl<'d, A, DEV> HostClass<'d, A> for GipHost<'d, A, DEV>
where A: UsbHostAllocator<'d>, DEV: GipDevice,

Source§

const NAME: &'static str = "GIP"

Source§

type Info = GipInterfaceInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for CcidHost<'d, A>

Source§

const NAME: &'static str = "CCID"

Source§

type Info = CcidInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for CdcAcmHost<'d, A>

Source§

const NAME: &'static str = "CDC ACM"

Source§

type Info = CdcAcmInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for HidHost<'d, A>

Source§

const NAME: &'static str = "HID"

Source§

type Info = HidInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for Midi2Host<'d, A>

Source§

const NAME: &'static str = "MIDI 2.0"

Source§

type Info = MidiInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for MidiHost<'d, A>

Source§

const NAME: &'static str = "MIDI 1.0"

Source§

type Info = MidiInfo

Source§

impl<'d, A: UsbHostAllocator<'d>> HostClass<'d, A> for MscDevice<'d, A>

Source§

const NAME: &'static str = "MSC"

Source§

type Info = MscInfo