Skip to main content

NetworkDeviceImplLocalServerHandler

Trait NetworkDeviceImplLocalServerHandler 

Source
pub trait NetworkDeviceImplLocalServerHandler<___T: Transport = DriverChannel> {
    // Required methods
    fn init(
        &mut self,
        request: Request<Init, ___T>,
        responder: Responder<Init, ___T>,
    ) -> impl Future<Output = ()>;
    fn start(
        &mut self,
        responder: Responder<Start, ___T>,
    ) -> impl Future<Output = ()>;
    fn stop(
        &mut self,
        responder: Responder<Stop, ___T>,
    ) -> impl Future<Output = ()>;
    fn get_info(
        &mut self,
        responder: Responder<GetInfo, ___T>,
    ) -> impl Future<Output = ()>;
    fn queue_tx(
        &mut self,
        request: Request<QueueTx, ___T>,
    ) -> impl Future<Output = ()>;
    fn queue_rx_space(
        &mut self,
        request: Request<QueueRxSpace, ___T>,
    ) -> impl Future<Output = ()>;
    fn prepare_vmo(
        &mut self,
        request: Request<PrepareVmo, ___T>,
        responder: Responder<PrepareVmo, ___T>,
    ) -> impl Future<Output = ()>;
    fn release_vmo(
        &mut self,
        request: Request<ReleaseVmo, ___T>,
        responder: Responder<ReleaseVmo, ___T>,
    ) -> impl Future<Output = ()>;
}
Expand description

A server handler for the NetworkDeviceImpl protocol.

See NetworkDeviceImpl for more details.

Required Methods§

Source

fn init( &mut self, request: Request<Init, ___T>, responder: Responder<Init, ___T>, ) -> impl Future<Output = ()>

Initializes the network device.

Init is only called once during the lifetime of the device to register iface as the callback target for the Network Device implementation.

Upon initialization, the device is expected to be in the “Stopped” state, the Start method will be called once the data path needs to be opened.

  • request iface handle to the device interface.
  • response s initialization status. A value other than ZX_OK will cause the device to unbind.
Source

fn start( &mut self, responder: Responder<Start, ___T>, ) -> impl Future<Output = ()>

Starts the device’s data path.

start signals to the device implementation that it should bring up its data path and be ready to receive tx frames and iface will start accepting rx frames.

The device is only considered started once Start returns successfully. Until then, the contract guarantees that no other data-path calls will be made to the device (QueueTx, RxAvailable, Stop, or a second call to Start), so implementers can safely assume or assert that this contract is upheld.

  • response s start status. ZX_OK indicates a successful start. ZX_ERR_ALREADY_BOUND indicates that the device has already been successfully started. Any other status value indicates an implementation specific error.
Source

fn stop(&mut self, responder: Responder<Stop, ___T>) -> impl Future<Output = ()>

Stops the network device.

The device implementation must return all outstanding Tx and Rx buffers upon receiving this call. Any new buffers received in the stopped state must be returned with an appropriate error (tx) or unfulfilled (rx). See [NetworkDeviceIfc.CompleteTx] and [NetworkDeviceIfc.CompleteRx] for details.

The device implementation may perform any power saving measures after observing stop.

Source

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

Gets information about the device.

Device information must not change over the course of the lifetime of the device.

  • response info device information.
Source

fn queue_tx( &mut self, request: Request<QueueTx, ___T>, ) -> impl Future<Output = ()>

Enqueues a list of buffers for transmission on the network device.

The driver takes ownership of the buffer and must complete the tx transaction by using [NetworkDeviceIfc.CompleteTx] operations once it is done with each buffer in buffers.

The total number of outstanding tx buffers given to a device will never exceed the reported [DeviceInfo.tx_depth] value. Which also means that no more than tx_depth buffers are going to be informed at once in a single call to QueueTx.

Buffers enqueued while the device in is the stopped state must be returned with an appropriate error. See [TxResult.status] for specific error codes.

  • request buffers tx buffers to enqueue for sending.
Source

fn queue_rx_space( &mut self, request: Request<QueueRxSpace, ___T>, ) -> impl Future<Output = ()>

Enqueues a list of rx buffer space on the network device.

The driver takes ownership of the buffer and must complete the transaction (once network data arrives) using [NetworkDeviceIfc.CompleteRx].

The total number of outstanding rx buffers given to a device will never exceed the reported [DeviceInfo.rx_depth] value. Which also means that no more than rx_depth buffers are going to be informed at once in a single call to QueueRxSpace.

Buffers enqueued while the device in is the stopped state must be returned with a zero length.

  • request buffers rx space buffers to be filled with network data when it arrives.
Source

fn prepare_vmo( &mut self, request: Request<PrepareVmo, ___T>, responder: Responder<PrepareVmo, ___T>, ) -> impl Future<Output = ()>

Informs device that a new VMO is being used to store frame data.

Implementers must store the VMO handle referenced by id until [NetworkDeviceImpl.ReleaseVmo] is called with the same id.

  • request id identifier used to reference this VMO.
  • request vmo VMO where frame data will be stored.
  • response s vmo registration status. ZX_OK indicates a successful VMO preparation. Any other status value indicates an implementation specific error and causes the client session which owns the VMO to be closed.
Source

fn release_vmo( &mut self, request: Request<ReleaseVmo, ___T>, responder: Responder<ReleaseVmo, ___T>, ) -> impl Future<Output = ()>

Device may dispose of all references to the VMO referenced by id.

No more buffers will be sent with this id.

ReleaseVmo is guaranteed to only be called when the implementation holds no buffers that reference that id.

  • request id VMO identifier.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<___H, ___T> NetworkDeviceImplLocalServerHandler<___T> for Local<___H>
where ___H: NetworkDeviceImplServerHandler<___T>, ___T: Transport,

Source§

async fn init( &mut self, request: Request<Init, ___T>, responder: Responder<Init, ___T>, )

Source§

async fn start(&mut self, responder: Responder<Start, ___T>)

Source§

async fn stop(&mut self, responder: Responder<Stop, ___T>)

Source§

async fn get_info(&mut self, responder: Responder<GetInfo, ___T>)

Source§

async fn queue_tx(&mut self, request: Request<QueueTx, ___T>)

Source§

async fn queue_rx_space(&mut self, request: Request<QueueRxSpace, ___T>)

Source§

async fn prepare_vmo( &mut self, request: Request<PrepareVmo, ___T>, responder: Responder<PrepareVmo, ___T>, )

Source§

async fn release_vmo( &mut self, request: Request<ReleaseVmo, ___T>, responder: Responder<ReleaseVmo, ___T>, )

Implementors§