embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

GudClass

Struct GudClass 

Source
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>

Source

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.

Source

pub async fn wait_connection(&mut self)

Wait until the host has configured the interface (bulk endpoint enabled).

This future is cancel-safe.

Source

pub async fn next_event(&self) -> GudEvent

Wait for the next host-side event, in request order.

This future is cancel-safe.

Source

pub fn try_next_event(&self) -> Option<GudEvent>

Try to receive the next host-side event without waiting.

Source

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.

Source

pub fn committed_state(&self) -> Option<DisplayState>

Latest state set by SET_STATE_COMMIT.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'d, D> !RefUnwindSafe for GudClass<'d, D>

§

impl<'d, D> !UnwindSafe for GudClass<'d, D>

§

impl<'d, D> Freeze for GudClass<'d, D>
where <D as Driver<'d>>::EndpointOut: Freeze,

§

impl<'d, D> Send for GudClass<'d, D>
where <D as Driver<'d>>::EndpointOut: Send,

§

impl<'d, D> Sync for GudClass<'d, D>
where <D as Driver<'d>>::EndpointOut: Sync,

§

impl<'d, D> Unpin for GudClass<'d, D>
where <D as Driver<'d>>::EndpointOut: Unpin,

§

impl<'d, D> UnsafeUnpin for GudClass<'d, D>
where <D as Driver<'d>>::EndpointOut: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.