pub struct GudClass<'d, D: Driver<'d>> { /* private fields */ }Expand description
GUD USB display class.
One vendor-specific interface with a single bulk OUT endpoint carrying
framebuffer updates. Events (state changes, rectangle update announcements) arrive
on GudClass::next_event. Pixel transfer is read with GudClass::read_packet
or streamed through GudClass::read_buffer.
The Linux driver only binds when the device VID/PID pair is in its id table.
Implementations§
Source§impl<'d, D: Driver<'d>> GudClass<'d, D>
impl<'d, D: Driver<'d>> GudClass<'d, D>
Sourcepub fn new(
builder: &mut Builder<'d, D>,
state: &'d mut State<'d>,
config: &'d Config<'d>,
) -> Self
pub fn new( builder: &mut Builder<'d, D>, state: &'d mut State<'d>, config: &'d Config<'d>, ) -> Self
Create a new GUD class. Adds one vendor-specific interface with one bulk OUT endpoint and registers the control handler.
The builder’s control buffer must be at least Config::control_buf_len
bytes long. A smaller buffer cannot serve the advertised configuration
without truncating responses or rejecting state checks.
Sourcepub async fn wait_connection(&mut self)
pub async fn wait_connection(&mut self)
Wait until the host has configured the interface (bulk endpoint enabled).
This future is cancel-safe.
Sourcepub async fn next_event(&self) -> GudEvent
pub async fn next_event(&self) -> GudEvent
Wait for the next host-side event, in request order.
This future is cancel-safe.
Sourcepub fn try_next_event(&self) -> Option<GudEvent>
pub fn try_next_event(&self) -> Option<GudEvent>
Try to receive the next host-side event without waiting.
Sourcepub fn checked_state(&self) -> Option<DisplayState>
pub fn checked_state(&self) -> Option<DisplayState>
Latest state set by SET_STATE_CHECK.
This may differ from Self::committed_state until the host commits it.
Sourcepub fn committed_state(&self) -> Option<DisplayState>
pub fn committed_state(&self) -> Option<DisplayState>
Latest state set by SET_STATE_COMMIT.
Sourcepub async fn read_packet(
&mut self,
data: &mut [u8],
) -> Result<usize, EndpointError>
pub async fn read_packet( &mut self, data: &mut [u8], ) -> Result<usize, EndpointError>
Read one bulk packet, returning its byte count.
data must hold at least config.max_packet_size bytes. Read
BufferInfo::transfer_size bytes before awaiting the next event.
Not cancel-safe.
Sourcepub async fn read_buffer<E, F: AsyncFnMut(&[u8]) -> Result<usize, E>>(
&mut self,
info: &BufferInfo,
chunk: &mut [u8],
f: F,
) -> Result<usize, ReadBufferError<E>>
pub async fn read_buffer<E, F: AsyncFnMut(&[u8]) -> Result<usize, E>>( &mut self, info: &BufferInfo, chunk: &mut [u8], f: F, ) -> Result<usize, ReadBufferError<E>>
Stream info through an async callback, returning its total consumed bytes.
chunk must hold at least config.max_packet_size bytes.
Not cancel-safe. After an error, drain unread data or reset before another transfer.