Skip to main content

UsbProxy

Struct UsbProxy 

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

Implementations§

Source§

impl UsbProxy

Source

pub fn new(channel: AsyncChannel) -> Self

Create a new Proxy for fuchsia.hardware.usb/Usb.

Source

pub fn take_event_stream(&self) -> UsbEventStream

Get a Stream of events from the remote end of the protocol.

§Panics

Panics if the event stream was already taken.

Source

pub fn connect_to_endpoint( &self, ep_addr: u8, ep: ServerEnd<EndpointMarker>, ) -> QueryResponseFut<UsbConnectToEndpointResult, DefaultFuchsiaResourceDialect> ⓘ

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, ) -> QueryResponseFut<UsbSpeed, DefaultFuchsiaResourceDialect> ⓘ

Returns the negotiated bus speed of the USB device.

Source

pub fn get_device_id( &self, ) -> QueryResponseFut<u32, DefaultFuchsiaResourceDialect> ⓘ

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

Source

pub fn get_device_descriptor( &self, ) -> QueryResponseFut<UsbDeviceDescriptor, DefaultFuchsiaResourceDialect> ⓘ

Returns the USB device descriptor.

Source

pub fn get_configuration_descriptor( &self, config: u8, ) -> QueryResponseFut<UsbGetConfigurationDescriptorResult, DefaultFuchsiaResourceDialect> ⓘ

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, ) -> QueryResponseFut<u8, DefaultFuchsiaResourceDialect> ⓘ

Returns the bConfigurationValue of the currently active USB configuration.

Source

pub fn set_configuration( &self, configuration: u8, ) -> QueryResponseFut<UsbSetConfigurationResult, DefaultFuchsiaResourceDialect> ⓘ

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, ) -> QueryResponseFut<UsbSetInterfaceResult, DefaultFuchsiaResourceDialect> ⓘ

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], ) -> QueryResponseFut<UsbControlTransferResult, DefaultFuchsiaResourceDialect> ⓘ

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, ) -> QueryResponseFut<UsbEnableEndpointResult, DefaultFuchsiaResourceDialect> ⓘ

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, ) -> QueryResponseFut<UsbResetEndpointResult, DefaultFuchsiaResourceDialect> ⓘ

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 Clone for UsbProxy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UsbProxy

Source§

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

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

impl Proxy for UsbProxy

Source§

type Protocol = UsbMarker

The protocol which this Proxy controls.
Source§

fn from_channel(inner: AsyncChannel) -> Self

Create a proxy over the given channel.
Source§

fn into_channel(self) -> Result<AsyncChannel, Self>

Attempt to convert the proxy back into a channel. Read more
Source§

fn as_channel(&self) -> &AsyncChannel

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

fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>

Attempt to convert the proxy back into a client end. Read more
Source§

fn is_closed(&self) -> bool

Returns true if the proxy has received the PEER_CLOSED signal.
Source§

fn on_closed(&self) -> OnSignals<'_, Unowned<'_, NullableHandle>> ⓘ

Returns a future that completes when the proxy receives the PEER_CLOSED signal.
Source§

impl UsbProxyInterface for UsbProxy

Source§

type ConnectToEndpointResponseFut = QueryResponseFut<Result<(), i32>>

Source§

type GetDeviceSpeedResponseFut = QueryResponseFut<UsbSpeed>

Source§

type GetDeviceIdResponseFut = QueryResponseFut<u32>

Source§

type GetDeviceDescriptorResponseFut = QueryResponseFut<UsbDeviceDescriptor>

Source§

type GetConfigurationDescriptorResponseFut = QueryResponseFut<Result<Vec<u8>, i32>>

Source§

type GetConfigurationResponseFut = QueryResponseFut<u8>

Source§

type SetConfigurationResponseFut = QueryResponseFut<Result<(), i32>>

Source§

type SetInterfaceResponseFut = QueryResponseFut<Result<(), i32>>

Source§

type ControlTransferResponseFut = QueryResponseFut<Result<Vec<u8>, i32>>

Source§

type EnableEndpointResponseFut = QueryResponseFut<Result<(), i32>>

Source§

type ResetEndpointResponseFut = QueryResponseFut<Result<(), i32>>

Source§

fn connect_to_endpoint( &self, ep_addr: u8, ep: ServerEnd<EndpointMarker>, ) -> Self::ConnectToEndpointResponseFut

Source§

fn get_device_speed(&self) -> Self::GetDeviceSpeedResponseFut

Source§

fn get_device_id(&self) -> Self::GetDeviceIdResponseFut

Source§

fn get_device_descriptor(&self) -> Self::GetDeviceDescriptorResponseFut

Source§

fn get_configuration_descriptor( &self, config: u8, ) -> Self::GetConfigurationDescriptorResponseFut

Source§

fn get_configuration(&self) -> Self::GetConfigurationResponseFut

Source§

fn set_configuration( &self, configuration: u8, ) -> Self::SetConfigurationResponseFut

Source§

fn set_interface( &self, interface_number: u8, alt_setting: u8, ) -> Self::SetInterfaceResponseFut

Source§

fn control_transfer( &self, setup: &UsbSetup, timeout_ns: i64, write_data: &[u8], ) -> Self::ControlTransferResponseFut

Source§

fn enable_endpoint( &self, ep_desc: &UsbEndpointDescriptor, ss_com_desc: &UsbSsEpCompDescriptor, enable: bool, ) -> Self::EnableEndpointResponseFut

Source§

fn reset_endpoint(&self, ep_address: u8) -> Self::ResetEndpointResponseFut

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> FromClient for T
where T: Proxy,

Source§

type Protocol = <T as Proxy>::Protocol

The protocol.
Source§

fn from_client(value: ClientEnd<<T as FromClient>::Protocol>) -> T

Converts from a client.
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
Source§

impl<T> ProxyHasDomain for T
where T: Proxy,

Source§

fn domain(&self) -> ZirconClient

Get a “client” for this proxy. This is just an object which has methods for a few common handle creation operations.
§

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.