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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)