Implementation of Microsoft OS USB descriptors for usb-device. Currently only the new Microsoft OS 2.0 Descriptors standard is supported. Version 1.0 may be added in the future if needed.
This crate provides class MsOsUsbClass
that is responsible for sending MS OS USB descriptors
and appropriate BOS capabilities. It is meant to be configured using const
structures that
describe the descriptors, and const fn
methods that generate raw descriptor data, e.g. for WinUSB:
```rust use usbdmicrosoftos::{os20, MsOsUsbClass, WindowsVersion, utf16lit, utf16nullle_bytes};
const DESCRIPTORSET: os20::DescriptorSet = os20::DescriptorSet { version: WindowsVersion::MINIMAL, features: &[], configurations: &[ os20::ConfigurationSubset { configuration: 0, features: &[], functions: &[ os20::FunctionSubset { firstinterface: 3, features: &[ os20::FeatureDescriptor::CompatibleId { id: b"WINUSB\0\0", subid: b"\0\0\0\0\0\0\0\0", }, os20::FeatureDescriptor::RegistryProperty { datatype: os20::PropertyDataType::RegMutliSz, name: &utf16lit::utf16null!("DeviceInterfaceGUIDs"), data: &utf16nulllebytes!("{6b09aac4-333f-4467-9e23-f88b9e9d95f7}\0"), }, ] } ] } ], };
const CAPABILITIES: os20::Capabilities = os20::Capabilities { infos: &[ os20::CapabilityInfo { descriptors: &DESCRIPTORSET, altenumcmd: os20::ALTENUMCODENOT_SUPPORTED, } ], };
const DESCRIPTORSETBYTES: [u8; DESCRIPTORSET.size()] = DESCRIPTORSET.descriptor(); const CAPABILITIESBYTES: [u8; CAPABILITIES.datalen()] = CAPABILITIES.descriptor_data();
pub const fn class() -> MsOsUsbClass { MsOsUsbClass { os20capabilitiesdata: &CAPABILITIESBYTES, os20descriptorsets: &[&DESCRIPTORSET_BYTES], } } ```
Check test cases to see more examples from the specification.