pub struct Channel<T: ?Sized + 'static>(/* private fields */);
Expand description
Implements a message channel through the Fuchsia Driver Runtime
Implementations§
Source§impl<T: ?Sized + 'static> Channel<T>
impl<T: ?Sized + 'static> Channel<T>
Sourcepub fn create() -> Result<(Self, Self), Status>
pub fn create() -> Result<(Self, Self), Status>
Creates a new channel pair that can be used to send messages of type T
between threads managed by the driver runtime.
Sourcepub fn into_driver_handle(self) -> DriverHandle
pub fn into_driver_handle(self) -> DriverHandle
Takes the inner handle to the channel. The caller is responsible for ensuring that the handle is freed.
Sourcepub unsafe fn from_driver_handle(handle: DriverHandle) -> Self
pub unsafe fn from_driver_handle(handle: DriverHandle) -> Self
Initializes a Channel
object from the given DriverHandle
,
assuming that it is a channel of type T
.
§Safety
The caller must ensure that the handle is a Channel
-based handle that is
using type T
as its wire format.
Sourcepub fn write(&self, message: Message<T>) -> Result<(), Status>
pub fn write(&self, message: Message<T>) -> Result<(), Status>
Writes the Message
given to the channel. This will complete asynchronously and can’t
be cancelled.
The channel will take ownership of the data and handles passed in,
Sourcepub fn write_with<F>(&self, arena: Arena, f: F) -> Result<(), Status>
pub fn write_with<F>(&self, arena: Arena, f: F) -> Result<(), Status>
Shorthand for calling Self::write
with the result of Message::new_with
Sourcepub fn write_with_data<F>(&self, arena: Arena, f: F) -> Result<(), Status>
pub fn write_with_data<F>(&self, arena: Arena, f: F) -> Result<(), Status>
Shorthand for calling Self::write
with the result of Message::new_with
Source§impl<T> Channel<T>
impl<T> Channel<T>
Source§impl Channel<[u8]>
impl Channel<[u8]>
Sourcepub fn try_read_bytes<'a>(&self) -> Result<Option<Message<[u8]>>, Status>
pub fn try_read_bytes<'a>(&self) -> Result<Option<Message<[u8]>>, Status>
Attempts to read an object of type T
and a handle set from the channel
Sourcepub async fn read_bytes(
&self,
dispatcher: DispatcherRef<'_>,
) -> Result<Option<Message<[u8]>>, Status>
pub async fn read_bytes( &self, dispatcher: DispatcherRef<'_>, ) -> Result<Option<Message<[u8]>>, Status>
Reads a slice of type T
and a handle set from the channel asynchronously