pub trait Client<'a, T: UsbHidType> {
    fn packet_received(
        &'a self,
        result: Result<(), ErrorCode>,
        buffer: &'static mut T,
        endpoint: usize
    ); fn packet_transmitted(
        &'a self,
        result: Result<(), ErrorCode>,
        buffer: &'static mut T,
        endpoint: usize
    ); fn can_receive(&'a self) -> bool; }
Expand description

Implement this trait and use set_client() in order to receive callbacks.

Required Methods

Called when a packet is received. This will return the buffer passed into receive_buffer() as well as the endpoint where the data was received. If the buffer length is smaller then the data length the buffer will only contain part of the packet and result will contain indicate an SIZE error. Result will indicate CANCEL if a receive was cancelled by receive_cancel() but the callback still occurred. See receive_cancel() for more details.

Called when a packet has been finished transmitting. This will return the buffer passed into send_buffer() as well as the endpoint where the data was sent. If not all of the data could be sent the result will contain the SIZE error. Result will indicate CANCEL if a send was cancelled by send_cancel() but the callback still occurred. See send_cancel() for more details.

Called when checking if we can start a new receive operation. Should return true if we are ready to receive and not currently in the process of receiving anything. That is if we are currently idle. If there is an outstanding call to receive, a callback already waiting to be called then this will return false.

Implementors