Skip to main content

Client

Struct Client 

Source
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,

Source

pub async fn connect(path: impl AsRef<Path>) -> Result<Client<P>, ClientError>

Connect a native endpoint with a single total setup deadline.

Source

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.

Source

pub async fn connect_connector( connector: &dyn Connector, ) -> Result<Client<P>, ClientError>

Connect through a supplied repeatable dialer.

Source

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.

Source

pub async fn connect_stream( stream: impl ByteTransport, ) -> Result<Client<P>, ClientError>

Establish the protocol on an exclusively owned caller transport.

Source

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.

Source

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.

Source

pub fn ready(&self) -> &<P as Protocol>::Ready

Shared immutable ready/welcome metadata.

Source

pub fn is_closed(&self) -> bool

Whether the shared connection has terminated.

Source

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.

Source

pub async fn close(&self)

Close all shared handles and wake every waiter; never reconnect implicitly.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn request_raw( &self, flags: u8, body: Vec<u8>, ) -> Result<RawFrame, ClientError>

Return one raw frame without decoding or normalizing its envelope.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn send_raw( &self, id: u32, flags: u8, body: &[u8], ) -> Result<(), ClientError>

Send an opaque envelope on a currently live owned ID.

Source

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.

Trait Implementations§

Source§

impl<P> Clone for Client<P>
where P: Protocol,

Source§

fn clone(&self) -> Client<P>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<P> !RefUnwindSafe for Client<P>

§

impl<P> !UnwindSafe for Client<P>

§

impl<P> Freeze for Client<P>
where Arc<Owner<P>>: Freeze,

§

impl<P> Send for Client<P>
where Arc<Owner<P>>: Send,

§

impl<P> Sync for Client<P>
where Arc<Owner<P>>: Sync,

§

impl<P> Unpin for Client<P>
where Arc<Owner<P>>: Unpin,

§

impl<P> UnsafeUnpin for Client<P>
where Arc<Owner<P>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more