pub enum DeviceRequest {
Clone {
request: ServerEnd<CloneableMarker>,
control_handle: DeviceControlHandle,
},
Close {
responder: DeviceCloseResponder,
},
Query {
responder: DeviceQueryResponder,
},
Read {
count: u64,
responder: DeviceReadResponder,
},
Write {
data: Vec<u8>,
responder: DeviceWriteResponder,
},
Describe {
responder: DeviceDescribeResponder,
},
OpenClient {
id: u32,
client: ServerEnd<DeviceMarker>,
responder: DeviceOpenClientResponder,
},
ClrSetFeature {
clr: u32,
set: u32,
responder: DeviceClrSetFeatureResponder,
},
GetWindowSize {
responder: DeviceGetWindowSizeResponder,
},
MakeActive {
client_pty_id: u32,
responder: DeviceMakeActiveResponder,
},
ReadEvents {
responder: DeviceReadEventsResponder,
},
SetWindowSize {
size: WindowSize,
responder: DeviceSetWindowSizeResponder,
},
}
Variants§
Clone
Close
Terminates the connection.
After calling Close
, the client must not send any other requests.
Servers, after sending the status response, should close the connection regardless of status and without sending an epitaph.
Closing the client end of the channel should be semantically equivalent
to calling Close
without knowing when the close has completed or its
status.
Fields
responder: DeviceCloseResponder
Query
Fields
responder: DeviceQueryResponder
Read
Reads up to ‘count’ bytes at the seek offset. The seek offset is moved forward by the number of bytes read.
§Invariants
- The returned
data.length
will never be greater thancount
. - If
data.length
is less thancount
, it means that the seek offset has reached the end of file as part of this operation. - If
data.length
is zero whilecount
is not, it means that the seek offset is already at or beyond the end of file, and no data could be read. - If
count
is zero, the server should perform all the checks ensuring read access without actually read anything, and return an emptydata
vector.
This method requires the [Rights.READ_BYTES
] right.
Returns ZX_ERR_OUT_OF_RANGE
if count
is greater than MAX_TRANSFER_SIZE
.
Write
Writes data at the seek offset. The seek offset is moved forward by the number of bytes written. If the file is in append mode, the seek offset is first set to the end of the file, followed by the write, in one atomic step.
The file size may grow if the seek offset plus data.length
is beyond
the current end of file.
- request
data
the byte buffer to write to the file.
- response
actual_count
the number of bytes written.
§Invariants
- The returned
actual_count
will never be greater thandata.length
. - If the server is unable to write all the data due to e.g. not enough
space,
actual_count
may be less thandata.length
. If no bytes could be written, an error is returned. - If
data.length
is zero, the server should perform all the checks ensuring write access without mutating the file and return a successful write of zero bytes. The seek offset is still updated if in append mode.
This method requires the [Rights.WRITE_BYTES
] right.
Describe
Fields
responder: DeviceDescribeResponder
OpenClient
Open a client PTY device with a unique id
. client
should be a handle
to one endpoint of a channel that (on success) will become an open
connection to the newly created device. On failure, the channel will be
closed. Closing the channel will close the connection and release the
device. If the provided id
is 0, then the new client is a controlling
client and has the capability to open additional clients. If the
current device is not a controlling client, ZX_ERR_ACCESS_DENIED
will be
returned. If id
is not unique, ZX_ERR_INVALID_ARGS
will be returned.
Otherwise the status code from device_add
is passed on.
ClrSetFeature
§allowed on Client PTYs
Clear and/or Set PTY Features
GetWindowSize
Obtain the window size (in character cells)
Fields
responder: DeviceGetWindowSizeResponder
MakeActive
§allowed on the Controlling PTY
Select which Client PTY receives input. Reads will simply block on non-active PTYs.
ReadEvents
Returns pending OOB events, simultaneously clearing them
Fields
responder: DeviceReadEventsResponder
SetWindowSize
§allowed on the Server PTY
Sets the window size
Implementations§
Source§impl DeviceRequest
impl DeviceRequest
pub fn into_clone( self, ) -> Option<(ServerEnd<CloneableMarker>, DeviceControlHandle)>
pub fn into_close(self) -> Option<DeviceCloseResponder>
pub fn into_query(self) -> Option<DeviceQueryResponder>
pub fn into_read(self) -> Option<(u64, DeviceReadResponder)>
pub fn into_write(self) -> Option<(Vec<u8>, DeviceWriteResponder)>
pub fn into_describe(self) -> Option<DeviceDescribeResponder>
pub fn into_open_client( self, ) -> Option<(u32, ServerEnd<DeviceMarker>, DeviceOpenClientResponder)>
pub fn into_clr_set_feature( self, ) -> Option<(u32, u32, DeviceClrSetFeatureResponder)>
pub fn into_get_window_size(self) -> Option<DeviceGetWindowSizeResponder>
pub fn into_make_active(self) -> Option<(u32, DeviceMakeActiveResponder)>
pub fn into_read_events(self) -> Option<DeviceReadEventsResponder>
pub fn into_set_window_size( self, ) -> Option<(WindowSize, DeviceSetWindowSizeResponder)>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL