[go: up one dir, main page]

Struct Channel

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn write( &self, bytes: &[u8], handles: &mut Vec<Handle>, ) -> Result<(), Status>

Write a message to a channel. Wraps the zx_channel_write syscall.

Source

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

Source§

fn as_handle_ref(&self) -> HandleRef<'_>

Get a reference to the handle. One important use of such a reference is for object_wait_many.
Source§

fn raw_handle(&self) -> zx_handle_t

Interpret the reference as a raw handle (an integer type). Two distinct handles will have different raw values (so it can perhaps be used as a key in a data structure).
Source§

fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>

Set and clear userspace-accessible signal bits on an object. Wraps the zx_object_signal syscall.
Source§

fn wait_handle( &self, signals: Signals, deadline: Time, ) -> Result<Signals, Status>

Waits on a handle. Wraps the zx_object_wait_one syscall.
Source§

fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>

Causes packet delivery on the given port when the object changes state and matches signals. zx_object_wait_async syscall.
Source§

impl AsRef<Channel> for Channel

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Channel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Channel> for Handle

Source§

fn from(x: Channel) -> Handle

Converts to this type from the input type.
Source§

impl From<Handle> for Channel

Source§

fn from(handle: Handle) -> Self

Converts to this type from the input type.
Source§

impl HandleBased for Channel

Source§

fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>

Duplicate a handle, possibly reducing the rights available. Wraps the zx_handle_duplicate syscall.
Source§

fn replace_handle(self, rights: Rights) -> Result<Self, Status>

Create a replacement for a handle, possibly reducing the rights available. This invalidates the original handle. Wraps the zx_handle_replace syscall.
Source§

fn into_handle(self) -> Handle

Converts the value into its inner handle. Read more
Source§

fn into_raw(self) -> zx_handle_t

Converts the handle into it’s raw representation. Read more
Source§

fn from_handle(handle: Handle) -> Self

Creates an instance of this type from a handle. Read more
Source§

fn into_handle_based<H: HandleBased>(self) -> H

Creates an instance of another handle-based type from this value’s inner handle.
Source§

fn from_handle_based<H: HandleBased>(h: H) -> Self

Creates an instance of this type from the inner handle of another handle-based type.
Source§

impl Hash for Channel

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Channel

Source§

fn eq(&self, other: &Channel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Peered for Channel

Source§

fn signal_peer( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>

Set and clear userspace-accessible signal bits on the object’s peer. Wraps the zx_object_signal_peer syscall.
Source§

impl Eq for Channel

Source§

impl StructuralPartialEq for Channel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.