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
Trait Implementations§
source§impl<T> From<Channel<T>> for MixedHandle
impl<T> From<Channel<T>> for MixedHandle
source§impl<T: Ord + ?Sized + 'static> Ord for Channel<T>
impl<T: Ord + ?Sized + 'static> Ord for Channel<T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq + ?Sized + 'static> PartialEq for Channel<T>
impl<T: PartialEq + ?Sized + 'static> PartialEq for Channel<T>
source§impl<T: PartialOrd + ?Sized + 'static> PartialOrd for Channel<T>
impl<T: PartialOrd + ?Sized + 'static> PartialOrd for Channel<T>
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