pub struct Client<P>where
P: Protocol,{ /* private fields */ }Expand description
Cheap shared handle to one reader, writer, allocator, and set of subscriptions.
Implementations§
Source§impl<P> Client<P>where
P: Protocol,
impl<P> Client<P>where
P: Protocol,
Sourcepub async fn connect(path: impl AsRef<Path>) -> Result<Client<P>, ClientError>
pub async fn connect(path: impl AsRef<Path>) -> Result<Client<P>, ClientError>
Connect a native endpoint with a single total setup deadline.
Sourcepub async fn connect_with(
path: impl AsRef<Path>,
configure: impl FnOnce(ConnectOptions) -> ConnectOptions,
) -> Result<Client<P>, ClientError>
pub async fn connect_with( path: impl AsRef<Path>, configure: impl FnOnce(ConnectOptions) -> ConnectOptions, ) -> Result<Client<P>, ClientError>
Configure a native connection without modifying its endpoint name.
Sourcepub async fn connect_connector(
connector: &dyn Connector,
) -> Result<Client<P>, ClientError>
pub async fn connect_connector( connector: &dyn Connector, ) -> Result<Client<P>, ClientError>
Connect through a supplied repeatable dialer.
Sourcepub async fn connect_connector_with(
connector: &dyn Connector,
configure: impl FnOnce(ConnectOptions) -> ConnectOptions,
) -> Result<Client<P>, ClientError>
pub async fn connect_connector_with( connector: &dyn Connector, configure: impl FnOnce(ConnectOptions) -> ConnectOptions, ) -> Result<Client<P>, ClientError>
Configure one deadline covering both dial and protocol establishment.
Sourcepub async fn connect_stream(
stream: impl ByteTransport,
) -> Result<Client<P>, ClientError>
pub async fn connect_stream( stream: impl ByteTransport, ) -> Result<Client<P>, ClientError>
Establish the protocol on an exclusively owned caller transport.
Sourcepub async fn connect_stream_with(
stream: impl ByteTransport,
configure: impl FnOnce(ConnectOptions) -> ConnectOptions,
) -> Result<Client<P>, ClientError>
pub async fn connect_stream_with( stream: impl ByteTransport, configure: impl FnOnce(ConnectOptions) -> ConnectOptions, ) -> Result<Client<P>, ClientError>
Configure setup for an already-dialed owned transport.
Sourcepub async fn from_established(
established: Established<<P as Protocol>::Ready>,
) -> Result<Client<P>, ClientError>
pub async fn from_established( established: Established<<P as Protocol>::Ready>, ) -> Result<Client<P>, ClientError>
Start routing after external protocol setup, validating ranges and limits.
Sourcepub async fn closed(&self)
pub async fn closed(&self)
Wait for shared closure, including an idle peer disconnect. Cancellation of this wait does not close the connection or affect other callers.
Sourcepub async fn close(&self)
pub async fn close(&self)
Close all shared handles and wake every waiter; never reconnect implicitly.
Sourcepub async fn request<M>(&self, message: M) -> Result<Message, ClientError>where
M: IntoOutboundMessage<P>,
pub async fn request<M>(&self, message: M) -> Result<Message, ClientError>where
M: IntoOutboundMessage<P>,
Return the first response and retain drain state if it is nonterminal.
Sourcepub async fn request_with<M>(
&self,
message: M,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<Message, ClientError>where
M: IntoOutboundMessage<P>,
pub async fn request_with<M>(
&self,
message: M,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<Message, ClientError>where
M: IntoOutboundMessage<P>,
Configure a local unary wait without imposing application success rules.
Sourcepub async fn request_typed<R>(
&self,
request: &R,
) -> Result<<R as Request<P>>::Response, <R as Request<P>>::Error>where
R: Request<P>,
pub async fn request_typed<R>(
&self,
request: &R,
) -> Result<<R as Request<P>>::Response, <R as Request<P>>::Error>where
R: Request<P>,
Execute a borrowed prepared request with optional checked result decoding.
Sourcepub async fn request_typed_with<R>(
&self,
request: &R,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<<R as Request<P>>::Response, <R as Request<P>>::Error>where
R: Request<P>,
pub async fn request_typed_with<R>(
&self,
request: &R,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<<R as Request<P>>::Response, <R as Request<P>>::Error>where
R: Request<P>,
Configure one checked unary attempt; unexpected streaming is an error.
Sourcepub async fn stream<M>(&self, message: M) -> Result<Stream<P>, ClientError>where
M: IntoOutboundMessage<P>,
pub async fn stream<M>(&self, message: M) -> Result<Stream<P>, ClientError>where
M: IntoOutboundMessage<P>,
Open a message stream on an owned correlation ID.
Sourcepub async fn stream_with<M>(
&self,
message: M,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<Stream<P>, ClientError>where
M: IntoOutboundMessage<P>,
pub async fn stream_with<M>(
&self,
message: M,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<Stream<P>, ClientError>where
M: IntoOutboundMessage<P>,
Configure the stream-opening wait; subsequent receives own their lifetime.
Sourcepub async fn request_raw(
&self,
flags: u8,
body: Vec<u8>,
) -> Result<RawFrame, ClientError>
pub async fn request_raw( &self, flags: u8, body: Vec<u8>, ) -> Result<RawFrame, ClientError>
Return one raw frame without decoding or normalizing its envelope.
Sourcepub async fn request_raw_with(
&self,
flags: u8,
body: Vec<u8>,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<RawFrame, ClientError>
pub async fn request_raw_with( &self, flags: u8, body: Vec<u8>, configure: impl FnOnce(RequestOptions) -> RequestOptions, ) -> Result<RawFrame, ClientError>
Set a deadline covering queue admission, write completion, and reply wait.
Sourcepub async fn stream_raw(
&self,
flags: u8,
body: Vec<u8>,
) -> Result<RawStream<P>, ClientError>
pub async fn stream_raw( &self, flags: u8, body: Vec<u8>, ) -> Result<RawStream<P>, ClientError>
Open an opaque stream with the same ID lease as native message streams.
Sourcepub async fn stream_raw_with(
&self,
flags: u8,
body: Vec<u8>,
configure: impl FnOnce(RequestOptions) -> RequestOptions,
) -> Result<RawStream<P>, ClientError>
pub async fn stream_raw_with( &self, flags: u8, body: Vec<u8>, configure: impl FnOnce(RequestOptions) -> RequestOptions, ) -> Result<RawStream<P>, ClientError>
Configure opaque stream opening without inspecting its envelope.
Sourcepub async fn send<M>(&self, id: u32, message: M) -> Result<(), ClientError>where
M: IntoOutboundMessage<P>,
pub async fn send<M>(&self, id: u32, message: M) -> Result<(), ClientError>where
M: IntoOutboundMessage<P>,
Send a native or encoded payload on a currently live owned ID.
Sourcepub async fn send_raw(
&self,
id: u32,
flags: u8,
body: &[u8],
) -> Result<(), ClientError>
pub async fn send_raw( &self, id: u32, flags: u8, body: &[u8], ) -> Result<(), ClientError>
Send an opaque envelope on a currently live owned ID.
Sourcepub async fn write_unchecked(&self, packet: Vec<u8>) -> Result<(), ClientError>
pub async fn write_unchecked(&self, packet: Vec<u8>) -> Result<(), ClientError>
Serialize exact packet bytes without allocating an ID or subscription. The caller owns packet semantics; byte limits and shared close still apply.