Struct hyperdriver::client::ClientService
source · pub struct ClientService<T, P, BOut = Body>{ /* private fields */ }client only.Expand description
A client which provides a simple HTTP tower::Service.
Client Services combine a transport (e.g. TCP) and a protocol (e.g. HTTP)
to provide a tower::Service that can be used to make requests to a server. Optionally, a connection
pool can be configured so that individual connections can be reused.
To use a client service, you must first poll the service to readiness with Service::poll_ready,
and then make the request with Service::call. This can be simplified with the tower::ServiceExt
which provides a Service::oneshot method that combines these two steps into a single future.
Implementations§
source§impl<P, T, BOut> ClientService<T, P, BOut>
impl<P, T, BOut> ClientService<T, P, BOut>
sourcepub fn new(transport: T, protocol: P, pool: Config) -> Self
pub fn new(transport: T, protocol: P, pool: Config) -> Self
Create a new client with the given transport, protocol, and pool configuration.
sourcepub fn without_pool(self) -> Self
pub fn without_pool(self) -> Self
Disable connection pooling for this client.
source§impl ClientService<TlsTransport<TcpTransport>, HttpConnectionBuilder, Body>
impl ClientService<TlsTransport<TcpTransport>, HttpConnectionBuilder, Body>
sourcepub fn new_tcp_http() -> Self
pub fn new_tcp_http() -> Self
Create a new client with the default configuration for making requests over TCP connections using the HTTP protocol.
When the tls feature is enabled, this will also add support for tls when
using the https scheme, with a default TLS configuration that will rely
on the system’s certificate store.
source§impl<P, C, T, BOut> ClientService<T, P, BOut>
impl<P, C, T, BOut> ClientService<T, P, BOut>
Trait Implementations§
source§impl<P, T, B> Clone for ClientService<T, P, B>
impl<P, T, B> Clone for ClientService<T, P, B>
source§impl<T, P, BOut: Debug> Debug for ClientService<T, P, BOut>
impl<T, P, BOut: Debug> Debug for ClientService<T, P, BOut>
source§impl<P, C, T, BIn, BOut> Service<Request<BIn>> for ClientService<T, P, BOut>
impl<P, C, T, BIn, BOut> Service<Request<BIn>> for ClientService<T, P, BOut>
§type Future = ResponseFuture<<P as Protocol<<T as Transport>::IO>>::Connection, TransportStream<<T as Transport>::IO>, BOut>
type Future = ResponseFuture<<P as Protocol<<T as Transport>::IO>>::Connection, TransportStream<<T as Transport>::IO>, BOut>
Auto Trait Implementations§
impl<T, P, BOut> Freeze for ClientService<T, P, BOut>
impl<T, P, BOut> RefUnwindSafe for ClientService<T, P, BOut>
impl<T, P, BOut> Send for ClientService<T, P, BOut>
impl<T, P, BOut> Sync for ClientService<T, P, BOut>
impl<T, P, BOut> Unpin for ClientService<T, P, BOut>
impl<T, P, BOut> UnwindSafe for ClientService<T, P, BOut>
Blanket Implementations§
source§impl<BIn, BOut, S> AdaptCustomBodyExt<BIn, BOut> for S
impl<BIn, BOut, S> AdaptCustomBodyExt<BIn, BOut> for S
source§fn adapt_custom_body(self) -> AdaptCustomBodyService<BIn, BOut, S>
fn adapt_custom_body(self) -> AdaptCustomBodyService<BIn, BOut, S>
Body as the outer body type.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)source§impl<T, B1, B2> HttpService<B1> for T
impl<T, B1, B2> HttpService<B1> for T
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<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
source§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
source§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService, that is a Service whose
response is another service. Read moresource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<S, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<S, C>
tokio only.MakeService, that will store C’s
associated ConnectInfo in a request extension such that ConnectInfo
can extract it. Read moresource§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
HandleError, that will handle errors
by converting them into responses. Read moresource§impl<T, Request> ServiceExt<Request> for T
impl<T, Request> ServiceExt<Request> for T
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready method. Read moresource§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready method. Read moresource§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready method. Read moresource§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read more