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§
Source§impl Channel
impl Channel
Sourcepub fn create() -> Result<(Channel, Channel), Status>
pub fn create() -> Result<(Channel, Channel), Status>
Create a channel, resulting an a pair of Channel objects representing both
sides of the channel. Messages written into one maybe read from the opposite.
Wraps the zx_channel_create syscall.
Sourcepub fn read_raw(
&self,
buf: &mut MessageBuf,
) -> Result<Result<(), Status>, (usize, usize)>
pub fn read_raw( &self, buf: &mut MessageBuf, ) -> Result<Result<(), Status>, (usize, usize)>
Read a message from a channel. Wraps the zx_channel_read syscall.
If the MessageBuf 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.
Sourcepub 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.
Sourcepub fn write(
&self,
bytes: &[u8],
handles: &mut Vec<Handle>,
) -> Result<(), Status>
pub fn write( &self, bytes: &[u8], handles: &mut Vec<Handle>, ) -> Result<(), Status>
Write a message to a channel. Wraps the zx_channel_write syscall.
Sourcepub fn call(
&self,
timeout: Time,
bytes: &[u8],
handles: &mut Vec<Handle>,
buf: &mut MessageBuf,
) -> Result<(), (Status, Status)>
pub fn call( &self, timeout: Time, bytes: &[u8], handles: &mut Vec<Handle>, buf: &mut MessageBuf, ) -> Result<(), (Status, Status)>
Send a message consisting of the given bytes and handles to a channel and await a reply. The bytes should start with a four byte ‘txid’ which is used to identify the matching reply.
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.
Trait Implementations§
Source§impl AsHandleRef for Channel
impl AsHandleRef for Channel
Source§fn as_handle_ref(&self) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
object_wait_many.