pub struct Client<T, E, Request>{ /* private fields */ }
Expand description
This type provides an implementation of a Tower
Service
on top of a
request-at-a-time protocol transport. In particular, it wraps a transport that implements
Sink<SinkItem = Request>
and Stream<Item = Response>
with the necessary bookkeeping to
adhere to Tower’s convenient fn(Request) -> Future<Response>
API.
Implementations§
Source§impl<T, E, Request> Client<T, E, Request>
impl<T, E, Request> Client<T, E, Request>
Sourcepub fn new(transport: T) -> Self
pub fn new(transport: T) -> Self
Construct a new Client
over the given transport
.
If the Client errors, the error is dropped when new
is used – use with_error_handler
to handle such an error explicitly.
Sourcepub fn with_error_handler<F>(transport: T, on_service_error: F) -> Self
pub fn with_error_handler<F>(transport: T, on_service_error: F) -> Self
Construct a new Client
over the given transport
.
If the Client
errors, its error is passed to on_service_error
.
Trait Implementations§
Source§impl<T, E, Request> Service<Request> for Client<T, E, Request>
impl<T, E, Request> Service<Request> for Client<T, E, Request>
Source§type Future = Pin<Box<dyn Future<Output = Result<<Client<T, E, Request> as Service<Request>>::Response, <Client<T, E, Request> as Service<Request>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<Client<T, E, Request> as Service<Request>>::Response, <Client<T, E, Request> as Service<Request>>::Error>> + Send>>
The future response value.
Auto Trait Implementations§
impl<T, E, Request> Freeze for Client<T, E, Request>
impl<T, E, Request> !RefUnwindSafe for Client<T, E, Request>
impl<T, E, Request> Send for Client<T, E, Request>
impl<T, E, Request> Sync for Client<T, E, Request>
impl<T, E, Request> Unpin for Client<T, E, Request>
impl<T, E, Request> !UnwindSafe for Client<T, E, Request>
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<M, T, Target, Request> MakeTransport<Target, Request> for M
impl<M, T, Target, Request> MakeTransport<Target, Request> for M
Source§fn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), <M as MakeTransport<Target, Request>>::MakeError>>
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <M as MakeTransport<Target, Request>>::MakeError>>
Returns
Ready
when the factory is able to create more transports. Read moreSource§fn make_transport(
&mut self,
target: Target,
) -> <M as MakeTransport<Target, Request>>::Future
fn make_transport( &mut self, target: Target, ) -> <M as MakeTransport<Target, Request>>::Future
Create and return a new transport asynchronously.