Struct fuchsia_zircon::MessageBuf
[−]
[src]
pub struct MessageBuf { /* fields omitted */ }
A buffer for receiving messages from a channel.
A MessageBuf
is essentially a byte buffer and a vector of
handles, but move semantics for "taking" handles requires special handling.
Note that for sending messages to a channel, the caller manages the buffers,
using a plain byte slice and Vec<Handle>
.
Methods
impl MessageBuf
[src]
fn new() -> Self
[src]
Create a new, empty, message buffer.
fn new_with(v: Vec<u8>, h: Vec<Handle>) -> Self
[src]
Create a new non-empty message buffer.
fn ensure_capacity_bytes(&mut self, n_bytes: usize)
[src]
Ensure that the buffer has the capacity to hold at least n_bytes
bytes.
fn ensure_capacity_handles(&mut self, n_handles: usize)
[src]
Ensure that the buffer has the capacity to hold at least n_handles
handles.
fn ensure_initialized_bytes(&mut self, n_bytes: usize)
[src]
Ensure that at least n_bytes bytes are initialized (0 fill).
fn bytes(&self) -> &[u8]
[src]
Get a reference to the bytes of the message buffer, as a &[u8]
slice.
fn n_handles(&self) -> usize
[src]
The number of handles in the message buffer. Note this counts the number
available when the message was received; take_handle
does not affect
the count.
fn take_handle(&mut self, index: usize) -> Option<Handle>
[src]
Take the handle at the specified index from the message buffer. If the
method is called again with the same index, it will return None
, as
will happen if the index exceeds the number of handles available.
fn clear(&mut self)
[src]
Clear the bytes and handles contained in the buf. This will drop any contained handles, resulting in their resources being freed.
Trait Implementations
impl Default for MessageBuf
[src]
fn default() -> MessageBuf
[src]
Returns the "default value" for a type. Read more