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
frame
inbound frame data and metadata.
- error
ZX_ERR_NOT_FOUND
if [Frame.port
] references an unknown port. - error
ZX_ERR_INVALID_ARGS
ifframe
is invalid. - error
ZX_ERR_BAD_STATE
if the device is offline. - error
ZX_ERR_BAD_STATE
if the device is offline. - error
ZX_ERR_NO_RESOURCES
if more than [fuchsia.net.tun/MAX_PENDING_OPERATIONS
] calls toWriteFrame
are pending. - error
ZX_ERR_SHOULD_WAIT
ifblocking
is set tofalse
and 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
frame
outbound frame data and metadata.
- error
ZX_ERR_NO_RESOURCES
if more than [fuchsia.net.tun/MAX_PENDING_OPERATIONS
] calls toReadFrame
are pending. - error
ZX_ERR_SHOULD_WAIT
ifblocking
is set tofalse
and there are no frames to be read.
Fields
responder: DeviceReadFrameResponder
GetSignals
Retrieves signals eventpair.
- response
signals
an eventpair that is signalled withSIGNAL_READABLE
andSIGNAL_WRITABLE
when read and write buffers are available, respectively.
Fields
responder: DeviceGetSignalsResponder
AddPort
Creates a new port on this device.
- request
config
new port configuration. - request
port
grants control over the port. Closed with an epitaph ifconfig
is not valid.
GetDevice
Connects to the underlying device endpoint.
- request
device
device 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