Trait kernel::hil::usb_hid::Client

source ·
pub trait Client<'a, T: UsbHidType> {
    // Required methods
    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§

source

fn packet_received( &'a self, result: Result<(), ErrorCode>, buffer: &'static mut T, endpoint: usize )

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.

source

fn packet_transmitted( &'a self, result: Result<(), ErrorCode>, buffer: &'static mut T, endpoint: usize )

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.

source

fn can_receive(&'a self) -> bool

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§