Skip to main content

UsbSynchronousProxy

Struct UsbSynchronousProxy 

Source
pub struct UsbSynchronousProxy { /* private fields */ }

Implementations§

Source§

impl UsbSynchronousProxy

Source

pub fn new(channel: Channel) -> Self

Source

pub fn into_channel(self) -> Channel

Source

pub fn wait_for_event( &self, deadline: MonotonicInstant, ) -> Result<UsbEvent, Error>

Waits until an event arrives and returns it. It is safe for other threads to make concurrent requests while waiting for an event.

Source

pub fn connect_to_endpoint( &self, ep_addr: u8, ep: ServerEnd<EndpointMarker>, ___deadline: MonotonicInstant, ) -> Result<UsbConnectToEndpointResult, Error>

Connects a channel to the specified USB endpoint (ep_addr).

Endpoint 0 (the default control pipe) cannot be connected via this method; use [ControlTransfer] instead.

Closing the [Usb] channel does not automatically close open [Endpoint] channels, which remain bound to the underlying host controller until explicitly closed by the client or disconnected when the physical USB device is unplugged.

  • error:
    • ZX_ERR_INVALID_ARGS if ep_addr refers to endpoint 0 or an endpoint number > 15.
    • ZX_ERR_NOT_FOUND if the device or endpoint address does not exist.
    • ZX_ERR_ALREADY_BOUND if the endpoint is already bound to an active channel.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.
Source

pub fn get_device_speed( &self, ___deadline: MonotonicInstant, ) -> Result<UsbSpeed, Error>

Returns the negotiated bus speed of the USB device.

Source

pub fn get_device_id(&self, ___deadline: MonotonicInstant) -> Result<u32, Error>

Returns the internal device ID assigned by the USB host controller / bus driver.

Source

pub fn get_device_descriptor( &self, ___deadline: MonotonicInstant, ) -> Result<UsbDeviceDescriptor, Error>

Returns the USB device descriptor.

Source

pub fn get_configuration_descriptor( &self, config: u8, ___deadline: MonotonicInstant, ) -> Result<UsbGetConfigurationDescriptorResult, Error>

Returns the full raw configuration descriptor hierarchy (in standard USB wire format) for the configuration with bConfigurationValue == config.

  • error:
    • ZX_ERR_INVALID_ARGS if config does not match any configuration descriptor on the device.
Source

pub fn get_configuration( &self, ___deadline: MonotonicInstant, ) -> Result<u8, Error>

Returns the bConfigurationValue of the currently active USB configuration.

Source

pub fn set_configuration( &self, configuration: u8, ___deadline: MonotonicInstant, ) -> Result<UsbSetConfigurationResult, Error>

Selects the active USB configuration (SET_CONFIGURATION) and updates the host controller state.

Replies after the SET_CONFIGURATION control transfer and controller state update complete.

  • error:
    • ZX_ERR_INVALID_ARGS if configuration does not match any configuration on the device.
    • ZX_ERR_TIMED_OUT if the control transfer times out.
    • ZX_ERR_IO_REFUSED if the device stalls the request.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.
    • ZX_ERR_NOT_SUPPORTED if invoked on an interface-scoped connection that prohibits device-wide configuration changes.
Source

pub fn set_interface( &self, interface_number: u8, alt_setting: u8, ___deadline: MonotonicInstant, ) -> Result<UsbSetInterfaceResult, Error>

Selects an alternate setting for the specified USB interface (SET_INTERFACE) and updates the host controller state.

Replies after the SET_INTERFACE control transfer and controller state update complete.

  • error:
    • ZX_ERR_INVALID_ARGS if interface_number or alt_setting is invalid.
    • ZX_ERR_TIMED_OUT if the control transfer times out.
    • ZX_ERR_IO_REFUSED if the device stalls the request.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.
Source

pub fn control_transfer( &self, setup: &UsbSetup, timeout_ns: i64, write_data: &[u8], ___deadline: MonotonicInstant, ) -> Result<UsbControlTransferResult, Error>

Performs a synchronous USB control transfer (IN or OUT) over endpoint 0.

Replies after the control transaction completes on the bus (and any associated host controller state updates for standard SET_CONFIGURATION or SET_INTERFACE requests finish).

While this method can be used to read descriptors, prefer [GetDeviceDescriptor] and [GetConfigurationDescriptor] when reading descriptors.

If timeout_ns is 0 or negative, a default 5-second timeout is used (per USB 2.0 Section 9.2.6.4).

  • error:
    • ZX_ERR_INVALID_ARGS if the setup packet length or write_data size is invalid.
    • ZX_ERR_TIMED_OUT if the control transfer does not complete within the timeout.
    • ZX_ERR_IO_REFUSED if the device returns a STALL handshake.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.
    • ZX_ERR_NOT_SUPPORTED if the server does not support raw control transfers.
Source

pub fn enable_endpoint( &self, ep_desc: &UsbEndpointDescriptor, ss_com_desc: &UsbSsEpCompDescriptor, enable: bool, ___deadline: MonotonicInstant, ) -> Result<UsbEnableEndpointResult, Error>

Enables or disables a USB endpoint on the host controller, configuring it as specified by the provided descriptors.

Replies after the host controller has updated its endpoint context and transfer ring state.

  • error:
    • ZX_ERR_INVALID_ARGS if the endpoint descriptor is invalid.
    • ZX_ERR_NO_RESOURCES if the host controller lacks bandwidth or resources.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.
    • ZX_ERR_NOT_SUPPORTED if the server does not support direct endpoint configuration.
Source

pub fn reset_endpoint( &self, ep_address: u8, ___deadline: MonotonicInstant, ) -> Result<UsbResetEndpointResult, Error>

Resets an endpoint on the host controller that is in a halted or error state, returning the host controller’s endpoint ring and data toggle to a normal running state.

Note: To clear a halt condition on a non-control endpoint, clients should also issue a standard CLEAR_FEATURE(ENDPOINT_HALT) control request to the device to reset the device’s data toggle to DATA0.

  • error:
    • ZX_ERR_INVALID_ARGS if the endpoint is not halted or the address is invalid.
    • ZX_ERR_IO_NOT_PRESENT if the device has been disconnected.

Trait Implementations§

Source§

impl Debug for UsbSynchronousProxy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Channel> for UsbSynchronousProxy

Available on Fuchsia only.
Source§

fn from(value: Channel) -> Self

Converts to this type from the input type.
Source§

impl From<UsbSynchronousProxy> for NullableHandle

Available on Fuchsia only.
Source§

fn from(value: UsbSynchronousProxy) -> Self

Converts to this type from the input type.
Source§

impl FromClient for UsbSynchronousProxy

Available on Fuchsia only.
Source§

type Protocol = UsbMarker

The protocol.
Source§

fn from_client(value: ClientEnd<UsbMarker>) -> Self

Converts from a client.
Source§

impl SynchronousProxy for UsbSynchronousProxy

Available on Fuchsia only.
Source§

type Proxy = UsbProxy

The async proxy for the same protocol.
Source§

type Protocol = UsbMarker

The protocol which this Proxy controls.
Source§

fn from_channel(inner: Channel) -> Self

Create a proxy over the given channel.
Source§

fn into_channel(self) -> Channel

Convert the proxy back into a channel.
Source§

fn as_channel(&self) -> &Channel

Get a reference to the proxy’s underlying channel. Read more
Source§

fn is_closed(&self) -> Result<bool, Status>

Returns true if the proxy has received the PEER_CLOSED signal. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, !>

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.