pub trait HidDevice {
    type Info: DeviceInfo;

    fn send(&self, data: &[u8]) -> Result<(), RequestError>;
    fn receive<'a>(
        buffer: &'a mut [u8],
        timeout: Option<Duration>
    ) -> Result<&'a [u8], ResponseError>; }
Expand description

A HID device.

The HID device must provide be able to send and receive packets with a fixed size.

Required Associated Types

The type for information about this device.

Required Methods

Sends a packet with the given data to the device.

Receives a packet from the device, writes its data to the given buffer and returns a slice of the buffer containing the response data.

If the received data includes a report number, it is not part of the returned slice. The buffer must be longer than the DeviceInfo::packet_size. If the device does not send a packet within the given timeout, ResponseError::Timeout must be returned.

Implementations on Foreign Types