Struct fidl::handle::fuchsia_handles::Channel
pub struct Channel(/* private fields */);
Expand description
An object representing a Zircon channel.
As essentially a subtype of Handle
, it can be freely interconverted.
Implementations§
§impl Channel
impl Channel
pub fn create() -> (Channel, Channel)
pub fn create() -> (Channel, Channel)
Create a channel, resulting in a pair of Channel
objects representing both
sides of the channel. Messages written into one may be read from the opposite.
Wraps the zx_channel_create syscall.
Panics
If the process’ job policy denies channel creation or the kernel reports no memory available to create a new channel.
pub fn read_raw(
&self,
bytes: &mut [u8],
handles: &mut [MaybeUninit<Handle>]
) -> Result<(Result<(), Status>, usize, usize), (usize, usize)>
pub fn read_raw( &self, bytes: &mut [u8], handles: &mut [MaybeUninit<Handle>] ) -> Result<(Result<(), Status>, usize, usize), (usize, usize)>
Read a message from a channel. Wraps the zx_channel_read syscall.
If the slice lacks the capacity to hold the pending message,
returns an Err
with the number of bytes and number of handles needed.
Otherwise returns an Ok
with the result as usual.
If both the outer and inner Result
s are Ok
, then the caller can
assume that the handles
array is initialized.
Note that read_slice
may call read_raw
with some uninitialized
elements because it resizes the input vector to its capacity
without initializing all of the elements.
pub fn read(&self, buf: &mut MessageBuf) -> Result<(), Status>
pub fn read(&self, buf: &mut MessageBuf) -> Result<(), Status>
Read a message from a channel.
Note that this method can cause internal reallocations in the MessageBuf
if it is lacks capacity to hold the full message. If such reallocations
are not desirable, use read_raw
instead.
pub fn read_split(
&self,
bytes: &mut Vec<u8>,
handles: &mut Vec<Handle>
) -> Result<(), Status>
pub fn read_split( &self, bytes: &mut Vec<u8>, handles: &mut Vec<Handle> ) -> Result<(), Status>
Read a message from a channel into a separate byte vector and handle vector.
Note that this method can cause internal reallocations in the Vec
s
if they lacks capacity to hold the full message. If such reallocations
are not desirable, use read_raw
instead.
pub fn read_etc_raw(
&self,
bytes: &mut [u8],
handle_infos: &mut [MaybeUninit<HandleInfo>]
) -> Result<(Result<(), Status>, usize, usize), (usize, usize)>
pub fn read_etc_raw( &self, bytes: &mut [u8], handle_infos: &mut [MaybeUninit<HandleInfo>] ) -> Result<(Result<(), Status>, usize, usize), (usize, usize)>
Read a message from a channel. Wraps the zx_channel_read_etc syscall.
This differs from read_raw
in that it returns extended information on
the handles.
If the slice lacks the capacity to hold the pending message,
returns an Err
with the number of bytes and number of handles needed.
Otherwise returns an Ok
with the result as usual.
If both the outer and inner Result
s are Ok
, then the caller can
assume that the handle_infos
array is initialized.
Note that read_etc_slice
may call read_etc_raw
with some
uninitialized elements because it resizes the input vector to its
capacity without initializing all of the elements.
pub fn read_etc(&self, buf: &mut MessageBufEtc) -> Result<(), Status>
pub fn read_etc(&self, buf: &mut MessageBufEtc) -> Result<(), Status>
Read a message from a channel.
This differs from read
in that it returns extended information on
the handles.
Note that this method can cause internal reallocations in the MessageBufEtc
if it is lacks capacity to hold the full message. If such reallocations
are not desirable, use read_etc_raw
instead.
pub fn read_etc_split(
&self,
bytes: &mut Vec<u8>,
handle_infos: &mut Vec<HandleInfo>
) -> Result<(), Status>
pub fn read_etc_split( &self, bytes: &mut Vec<u8>, handle_infos: &mut Vec<HandleInfo> ) -> Result<(), Status>
Read a message from a channel into a separate byte vector and handle vector.
This differs from read_split
in that it returns extended information on
the handles.
Note that this method can cause internal reallocations in the Vec
s
if they lacks capacity to hold the full message. If such reallocations
are not desirable, use read_raw
instead.
pub fn write(&self, bytes: &[u8], handles: &mut [Handle]) -> Result<(), Status>
pub fn write(&self, bytes: &[u8], handles: &mut [Handle]) -> Result<(), Status>
Write a message to a channel. Wraps the zx_channel_write syscall.
pub fn write_etc(
&self,
bytes: &[u8],
handle_dispositions: &mut [HandleDisposition<'_>]
) -> Result<(), Status>
pub fn write_etc( &self, bytes: &[u8], handle_dispositions: &mut [HandleDisposition<'_>] ) -> Result<(), Status>
Write a message to a channel. Wraps the zx_channel_write_etc syscall.
pub fn call(
&self,
timeout: Time,
bytes: &[u8],
handles: &mut [Handle],
buf: &mut MessageBuf
) -> Result<(), Status>
pub fn call( &self, timeout: Time, bytes: &[u8], handles: &mut [Handle], buf: &mut MessageBuf ) -> Result<(), Status>
Send a message consisting of the given bytes and handles to a channel and await a reply.
The first four bytes of the written and read back messages are treated as a transaction ID
of type zx_txid_t
. The kernel generates a txid for the written message, replacing that
part of the message as read from userspace. In other words, the first four bytes of
bytes
will be ignored, and the first four bytes of the response will contain a
kernel-generated txid.
Wraps the zx_channel_call syscall.
Note that unlike read
, the caller must ensure that the MessageBuf has enough
capacity for the bytes and handles which will be received, as replies which are too large
are discarded.
On failure returns the both the main and read status.
pub fn call_etc(
&self,
timeout: Time,
bytes: &[u8],
handle_dispositions: &mut [HandleDisposition<'_>],
buf: &mut MessageBufEtc
) -> Result<(), Status>
pub fn call_etc( &self, timeout: Time, bytes: &[u8], handle_dispositions: &mut [HandleDisposition<'_>], buf: &mut MessageBufEtc ) -> Result<(), Status>
Send a message consisting of the given bytes and handles to a channel and await a reply.
The first four bytes of the written and read back messages are treated as a transaction ID
of type zx_txid_t
. The kernel generates a txid for the written message, replacing that
part of the message as read from userspace. In other words, the first four bytes of
bytes
will be ignored, and the first four bytes of the response will contain a
kernel-generated txid.
This differs from call
, in that it uses extended handle info.
Wraps the zx_channel_call_etc syscall.
Note that unlike read_etc
, the caller must ensure that the MessageBufEtc
has enough capacity for the bytes and handles which will be received, as replies which are
too large are discarded.
On failure returns the both the main and read status.
Trait Implementations§
§impl AsHandleRef for Channel
impl AsHandleRef for Channel
§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals ) -> Result<(), Status>
§fn wait_handle(
&self,
signals: Signals,
deadline: Time
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Time ) -> Result<Signals, Status>
§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts ) -> Result<(), Status>
§fn get_name(&self) -> Result<CString, Status>
fn get_name(&self) -> Result<CString, Status>
§fn set_name(&self, name: &CStr) -> Result<(), Status>
fn set_name(&self, name: &CStr) -> Result<(), Status>
§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
source§impl ChannelEpitaphExt for Channel
impl ChannelEpitaphExt for Channel
§impl HandleBased for Channel
impl HandleBased for Channel
§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere H: HandleBased,
§fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn from_handle_based<H>(h: H) -> Selfwhere H: HandleBased,
fn is_invalid_handle(&self) -> bool
§impl Ord for Channel
impl Ord for Channel
§impl PartialOrd for Channel
impl PartialOrd for Channel
§fn partial_cmp(&self, other: &Channel) -> Option<Ordering>
fn partial_cmp(&self, other: &Channel) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more