pub struct Client<D: ResourceDialect = DefaultFuchsiaResourceDialect> { /* private fields */ }
Expand description
A FIDL client which can be used to send buffers and receive responses via a channel.
Implementations§
source§impl<D: ResourceDialect> Client<D>
impl<D: ResourceDialect> Client<D>
sourcepub fn new(channel: D::ProxyChannel, protocol_name: &'static str) -> Client<D>
pub fn new(channel: D::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.
sourcepub fn as_channel(&self) -> &D::ProxyChannel
pub fn as_channel(&self) -> &D::ProxyChannel
Get a reference to the client’s underlying channel.
sourcepub fn into_channel(self) -> Result<D::ProxyChannel, Self>
pub fn into_channel(self) -> Result<D::ProxyChannel, 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<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.
sourcepub fn send<T: TypeMarker>(
&self,
body: impl Encode<T, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
) -> Result<(), Error>
pub fn send<T: TypeMarker>( &self, body: impl Encode<T, D>, 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, D>,
dynamic_flags: DynamicFlags,
) -> QueryResponseFut<Response::Owned, D> ⓘ
pub fn send_query<Request: TypeMarker, Response: TypeMarker, const ORDINAL: u64>( &self, body: impl Encode<Request, D>, dynamic_flags: DynamicFlags, ) -> QueryResponseFut<Response::Owned, D> ⓘ
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, D>,
ordinal: u64,
dynamic_flags: DynamicFlags,
decode: fn(_: Result<D::MessageBufEtc, Error>) -> Result<Output, Error>,
) -> QueryResponseFut<Output, D> ⓘ
pub fn send_query_and_decode<Request: TypeMarker, Output>( &self, body: impl Encode<Request, D>, ordinal: u64, dynamic_flags: DynamicFlags, decode: fn(_: Result<D::MessageBufEtc, Error>) -> Result<Output, Error>, ) -> QueryResponseFut<Output, D> ⓘ
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 [<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition],
) -> Result<(), Error>
pub fn send_raw( &self, bytes: &[u8], handles: &mut [<D::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition], ) -> Result<(), Error>
Sends a raw message without expecting a response.
sourcepub 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::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::ProxyChannel as ProxyChannelFor<D>>::HandleDisposition>) -> Result<(), Error>,
Sends a raw query and receives a response future.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Client<D>
impl<D = DefaultFuchsiaResourceDialect> !RefUnwindSafe for Client<D>
impl<D> Send for Client<D>
impl<D> Sync for Client<D>
impl<D> Unpin for Client<D>
impl<D = DefaultFuchsiaResourceDialect> !UnwindSafe for Client<D>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)