pub enum DeviceRequest {
WriteFrame {
frame: Frame,
responder: DeviceWriteFrameResponder,
},
ReadFrame {
responder: DeviceReadFrameResponder,
},
GetSignals {
responder: DeviceGetSignalsResponder,
},
AddPort {
config: DevicePortConfig,
port: ServerEnd<PortMarker>,
control_handle: DeviceControlHandle,
},
GetDevice {
device: ServerEnd<DeviceMarker>,
control_handle: DeviceControlHandle,
},
DelegateRxLease {
lease: DelegatedRxLease,
control_handle: DeviceControlHandle,
},
}Expand description
Provides control over the created device.
This protocol encodes the underlying object’s lifetime in both directions; the underlying object is alive iff both ends of the protocol are open. That is:
- Closing the client end causes the object to be destroyed.
- Observing a closure of the server end indicates the object no longer exists.
Variants§
WriteFrame
Writes a frame to the device (data coming from network-end).
If the device was created with the
[fuchsia.net.tun/DeviceConfig.blocking] option set to true, calls to
WriteFrame block until there is one buffer available to fulfill the
request.
- request
frameinbound frame data and metadata.
- error
ZX_ERR_NOT_FOUNDif [Frame.port] references an unknown port. - error
ZX_ERR_INVALID_ARGSifframeis invalid. - error
ZX_ERR_BAD_STATEif the device is offline. - error
ZX_ERR_NO_RESOURCESif more than [fuchsia.net.tun/MAX_PENDING_OPERATIONS] calls toWriteFrameare pending. - error
ZX_ERR_SHOULD_WAITifblockingis set tofalseand there are no buffers available to fulfill the request.
ReadFrame
Gets the next frame from the device (data coming from host-end).
If the device was created with the
[fuchsia.net.tun/DeviceConfig.blocking] option set to true, calls to
ReadFrame block until there is a frame available to be read.
- response
frameoutbound frame data and metadata.
- error
ZX_ERR_NO_RESOURCESif more than [fuchsia.net.tun/MAX_PENDING_OPERATIONS] calls toReadFrameare pending. - error
ZX_ERR_SHOULD_WAITifblockingis set tofalseand there are no frames to be read.
Fields
responder: DeviceReadFrameResponderGetSignals
Retrieves signals eventpair.
- response
signalsan eventpair that is signalled withSIGNAL_READABLEandSIGNAL_WRITABLEwhen read and write buffers are available, respectively.
Fields
responder: DeviceGetSignalsResponderAddPort
Creates a new port on this device.
- request
confignew port configuration. - request
portgrants control over the port. Closed with an epitaph ifconfigis not valid.
GetDevice
Connects to the underlying device endpoint.
- request
devicedevice handle.
DelegateRxLease
Delegates an rx lease through the tun device.
See documentation on [fuchsia.hardware.network/DelegatedRxLease] for
proper usage.
Implementations§
Source§impl DeviceRequest
impl DeviceRequest
pub fn into_write_frame(self) -> Option<(Frame, DeviceWriteFrameResponder)>
pub fn into_read_frame(self) -> Option<DeviceReadFrameResponder>
pub fn into_get_signals(self) -> Option<DeviceGetSignalsResponder>
pub fn into_add_port( self, ) -> Option<(DevicePortConfig, ServerEnd<PortMarker>, DeviceControlHandle)>
pub fn into_get_device( self, ) -> Option<(ServerEnd<DeviceMarker>, DeviceControlHandle)>
pub fn into_delegate_rx_lease( self, ) -> Option<(DelegatedRxLease, DeviceControlHandle)>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL