Skip to main content

DeviceServerHandler

Trait DeviceServerHandler 

Source
pub trait DeviceServerHandler<___T: Transport = DriverChannel> {
    // Required methods
    fn get_info(
        &mut self,
        responder: Responder<GetInfo, ___T>,
    ) -> impl Future<Output = ()> + Send;
    fn config(
        &mut self,
        request: Request<Config, ___T>,
        responder: Responder<Config, ___T>,
    ) -> impl Future<Output = ()> + Send;
    fn enable(
        &mut self,
        request: Request<Enable, ___T>,
        responder: Responder<Enable, ___T>,
    ) -> impl Future<Output = ()> + Send;
    fn read(
        &mut self,
        responder: Responder<Read, ___T>,
    ) -> impl Future<Output = ()> + Send;
    fn write(
        &mut self,
        request: Request<Write, ___T>,
        responder: Responder<Write, ___T>,
    ) -> impl Future<Output = ()> + Send;
    fn cancel_all(
        &mut self,
        responder: Responder<CancelAll, ___T>,
    ) -> impl Future<Output = ()> + Send;

    // Provided method
    fn on_unknown_interaction(
        &mut self,
        ordinal: u64,
    ) -> impl Future<Output = ()> + Send { ... }
}
Expand description

A server handler for the Device protocol.

See Device for more details.

Required Methods§

Source

fn get_info( &mut self, responder: Responder<GetInfo, ___T>, ) -> impl Future<Output = ()> + Send

Source

fn config( &mut self, request: Request<Config, ___T>, responder: Responder<Config, ___T>, ) -> impl Future<Output = ()> + Send

Configures the given serial port. Values of flags are defined in the constants above.

  • error one of the following values:
  • `ZX_ERR_IO_NOT_PRESENT`: The serial controller is in a low-power state or is
  •                          transitioning to a low-power state.
  • Other values may be returned for driver- or device-specific errors.
Source

fn enable( &mut self, request: Request<Enable, ___T>, responder: Responder<Enable, ___T>, ) -> impl Future<Output = ()> + Send

Enable or disable the device. If already enabled and enable is true, this is a no-op and returns successfully. If already disabled and enable is false, this is a no-op and returns successfully.

  • request enable true to enable the device, or false to disable it.
  • error one of the following values:
  • `ZX_ERR_BAD_STATE`: `enable` was false, and a `Read()` or `Write()` call was pending.
  • `ZX_ERR_IO_NOT_PRESENT`: The serial controller is in a low-power state or is
  •                          transitioning to a low-power state.
Source

fn read( &mut self, responder: Responder<Read, ___T>, ) -> impl Future<Output = ()> + Send

Perform a read operation. Returns immediately if data has been received since the last call; otherwise the request is completed the next time data is received (clients can use the hanging-get pattern to be notified of new data).

  • response data the bytes read from the device.
  • error one of the following values:
  • `ZX_ERR_BAD_STATE`: The device was not enabled.
  • `ZX_ERR_CANCELED`: The call was canceled by `CancelAll()`.
  • `ZX_ERR_ALREADY_BOUND`: Another `Read()` call was already pending.
  • `ZX_ERR_IO_NOT_PRESENT`: The serial controller is in a low-power state or is
  •                          transitioning to a low-power state.
  • Other values may be returned for driver- or device-specific errors.
Source

fn write( &mut self, request: Request<Write, ___T>, responder: Responder<Write, ___T>, ) -> impl Future<Output = ()> + Send

Perform a write operation. Returns when all bytes have been written, or when an error is encountered.

  • request data the bytes to write to the device.
  • error one of the following values:
  • `ZX_ERR_BAD_STATE`: The device was not enabled.
  • `ZX_ERR_CANCELED`: The call was canceled by `CancelAll()`.
  • `ZX_ERR_ALREADY_BOUND`: Another `Write()` call was already pending.
  • `ZX_ERR_IO_NOT_PRESENT`: The serial controller is in a low-power state or is
  •                          transitioning to a low-power state.
  • Other values may be returned for driver- or device-specific errors.
Source

fn cancel_all( &mut self, responder: Responder<CancelAll, ___T>, ) -> impl Future<Output = ()> + Send

Immediately cancels all outstanding asynchronous I/O

Provided Methods§

Source

fn on_unknown_interaction( &mut self, ordinal: u64, ) -> impl Future<Output = ()> + Send

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§