Struct Client
pub struct Client<D = DefaultFuchsiaResourceDialect>where
D: ResourceDialect,{ /* private fields */ }
Expand description
A FIDL client which can be used to send buffers and receive responses via a channel.
Implementations§
§impl<D> Client<D>where
D: ResourceDialect,
impl<D> Client<D>where
D: ResourceDialect,
pub fn new(
channel: <D as ResourceDialect>::ProxyChannel,
protocol_name: &'static str,
) -> Client<D>
pub fn new( channel: <D as ResourceDialect>::ProxyChannel, protocol_name: &'static str, ) -> Client<D>
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.
pub fn as_channel(&self) -> &<D as ResourceDialect>::ProxyChannel
pub fn as_channel(&self) -> &<D as ResourceDialect>::ProxyChannel
Get a reference to the client’s underlying channel.
pub fn into_channel(
self,
) -> Result<<D as ResourceDialect>::ProxyChannel, Client<D>>
pub fn into_channel( self, ) -> Result<<D as ResourceDialect>::ProxyChannel, Client<D>>
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.
pub fn take_event_receiver(&self) -> EventReceiver<D>
pub fn take_event_receiver(&self) -> EventReceiver<D>
Retrieve the stream of event messages for the Client
.
Panics if the stream was already taken.
pub fn send<T>(
&self,
body: impl Encode<T, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
) -> Result<(), Error>where
T: TypeMarker,
pub fn send<T>(
&self,
body: impl Encode<T, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
) -> Result<(), Error>where
T: TypeMarker,
Encodes and sends a request without expecting a response.
pub fn send_query<Request, Response, const ORDINAL: u64>(
&self,
body: impl Encode<Request, D>,
dynamic_flags: DynamicFlags,
) -> QueryResponseFut<<Response as TypeMarker>::Owned, D> ⓘwhere
Request: TypeMarker,
Response: TypeMarker,
<Response as TypeMarker>::Owned: Decode<Response, D>,
pub fn send_query<Request, Response, const ORDINAL: u64>(
&self,
body: impl Encode<Request, D>,
dynamic_flags: DynamicFlags,
) -> QueryResponseFut<<Response as TypeMarker>::Owned, D> ⓘwhere
Request: TypeMarker,
Response: TypeMarker,
<Response as TypeMarker>::Owned: Decode<Response, D>,
Encodes and sends a request. Returns a future that decodes the response.
pub fn send_query_and_decode<Request, Output>(
&self,
body: impl Encode<Request, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
decode: fn(_: Result<<D as ResourceDialect>::MessageBufEtc, Error>) -> Result<Output, Error>,
) -> QueryResponseFut<Output, D> ⓘwhere
Request: TypeMarker,
pub fn send_query_and_decode<Request, Output>(
&self,
body: impl Encode<Request, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
decode: fn(_: Result<<D as ResourceDialect>::MessageBufEtc, Error>) -> Result<Output, Error>,
) -> QueryResponseFut<Output, D> ⓘwhere
Request: TypeMarker,
Encodes and sends a request. Returns a future that decodes the response
using the given decode
function.
pub fn send_raw(
&self,
bytes: &[u8],
handles: &mut [<<D as ResourceDialect>::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition],
) -> Result<(), Error>
pub fn send_raw( &self, bytes: &[u8], handles: &mut [<<D as ResourceDialect>::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition], ) -> Result<(), Error>
Sends a raw message without expecting a response.
pub fn send_raw_query<F>(
&self,
encode_msg: F,
) -> Result<MessageResponse<D>, Error>where
F: for<'a, 'b> FnOnce(Txid, &'a mut Vec<u8>, &'b mut Vec<<<D as ResourceDialect>::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>) -> Result<(), Error>,
pub fn send_raw_query<F>(
&self,
encode_msg: F,
) -> Result<MessageResponse<D>, Error>where
F: for<'a, 'b> FnOnce(Txid, &'a mut Vec<u8>, &'b mut Vec<<<D as ResourceDialect>::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>) -> Result<(), Error>,
Sends a raw query and receives a response future.