pub struct Client { /* private fields */ }
Expand description
A FIDL client which can be used to send buffers and receive responses via a channel.
Implementations§
source§impl Client
impl Client
sourcepub fn new(channel: AsyncChannel, protocol_name: &'static str) -> Client
pub fn new(channel: AsyncChannel, protocol_name: &'static str) -> Client
Create a new client.
channel
is the asynchronous channel over which data is sent and received.
event_ordinals
are the ordinals on which events will be received.
sourcepub fn as_channel(&self) -> &AsyncChannel
pub fn as_channel(&self) -> &AsyncChannel
Get a reference to the client’s underlying channel.
sourcepub fn into_channel(self) -> Result<AsyncChannel, Self>
pub fn into_channel(self) -> Result<AsyncChannel, Self>
Attempt to convert the Client
back into a channel.
This will only succeed if there are no active clones of this Client
,
no currently-alive EventReceiver
or MessageResponse
s that came from
this Client
, and no outstanding messages awaiting a response, even if
that response will be discarded.
sourcepub fn take_event_receiver(&self) -> EventReceiver
pub fn take_event_receiver(&self) -> EventReceiver
Retrieve the stream of event messages for the Client
.
Panics if the stream was already taken.
sourcepub fn send<T: TypeMarker>(
&self,
body: impl Encode<T>,
ordinal: u64,
dynamic_flags: DynamicFlags
) -> Result<(), Error>
pub fn send<T: TypeMarker>( &self, body: impl Encode<T>, ordinal: u64, dynamic_flags: DynamicFlags ) -> Result<(), Error>
Encodes and sends a request without expecting a response.
sourcepub fn send_query<Request: TypeMarker, Response: TypeMarker, const ORDINAL: u64>(
&self,
body: impl Encode<Request>,
dynamic_flags: DynamicFlags
) -> QueryResponseFut<Response::Owned> ⓘ
pub fn send_query<Request: TypeMarker, Response: TypeMarker, const ORDINAL: u64>( &self, body: impl Encode<Request>, dynamic_flags: DynamicFlags ) -> QueryResponseFut<Response::Owned> ⓘ
Encodes and sends a request. Returns a future that decodes the response.
sourcepub fn send_query_and_decode<Request: TypeMarker, Output>(
&self,
body: impl Encode<Request>,
ordinal: u64,
dynamic_flags: DynamicFlags,
decode: fn(_: Result<MessageBufEtc, Error>) -> Result<Output, Error>
) -> QueryResponseFut<Output> ⓘ
pub fn send_query_and_decode<Request: TypeMarker, Output>( &self, body: impl Encode<Request>, ordinal: u64, dynamic_flags: DynamicFlags, decode: fn(_: Result<MessageBufEtc, Error>) -> Result<Output, Error> ) -> QueryResponseFut<Output> ⓘ
Encodes and sends a request. Returns a future that decodes the response
using the given decode
function.
sourcepub fn send_raw(
&self,
bytes: &[u8],
handles: &mut [HandleDisposition<'_>]
) -> Result<(), Error>
pub fn send_raw( &self, bytes: &[u8], handles: &mut [HandleDisposition<'_>] ) -> Result<(), Error>
Sends a raw message without expecting a response.
sourcepub fn send_raw_query<F>(&self, encode_msg: F) -> Result<MessageResponse, Error>
pub fn send_raw_query<F>(&self, encode_msg: F) -> Result<MessageResponse, Error>
Sends a raw query and receives a response future.