//! An example how to "extend"/add helper methods to //! `Device` by implementing a new trait for `Device` //! in a separate module. use usb_device::class::UsbClass; use usbd_class_tester::prelude::*; pub trait DeviceExt { fn custom_get_status(&mut self, cls: &mut T) -> core::result::Result, AnyUsbError>; } impl<'a, C, M> DeviceExt for Device<'a, C, M> where C: UsbClass, M: UsbDeviceCtx = C>, { fn custom_get_status(&mut self, cls: &mut C) -> core::result::Result, AnyUsbError> { let res = self.device_get_status(cls)?; Ok(res.to_le_bytes().into()) } }