pub struct OneshotService<Pr, C = HttpConnector, B = Body> { /* private fields */ }
http1
or http2
only.Expand description
A Service<Request<B>>
that sends a request and returns the response, owning a Client
.
let mut svc = OneshotService::http_default("example.com:1234", Static("bar")).unwrap();
let req = Request::builder()
.uri("https://myserver.com/foo")
.body(Body::empty())
.unwrap();
// http://example.com:1234/bar
let _res = svc.call(req).await.unwrap();
Implementations§
Source§impl<Pr, C, B> OneshotService<Pr, C, B>
impl<Pr, C, B> OneshotService<Pr, C, B>
Sourcepub fn from<S, A>(
client: Client<C, B>,
scheme: S,
authority: A,
path: Pr,
) -> Result<Self, HttpError>
pub fn from<S, A>( client: Client<C, B>, scheme: S, authority: A, path: Pr, ) -> Result<Self, HttpError>
Initializes a service with a general Client
.
A client can be built by functions in client
.
For the meaning of “scheme” and “authority”, refer to the documentation of
Uri
.
The path
should implement PathRewriter
.
Source§impl<Pr, B> OneshotService<Pr, HttpConnector, B>
impl<Pr, B> OneshotService<Pr, HttpConnector, B>
Sourcepub fn http_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
pub fn http_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
Use client::http_default()
to build a client.
For the meaning of “authority”, refer to the documentation of Uri
.
The path
should implement PathRewriter
.
Source§impl<Pr, B> OneshotService<Pr, HttpsConnector<HttpConnector>, B>
impl<Pr, B> OneshotService<Pr, HttpsConnector<HttpConnector>, B>
Sourcepub fn https_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
Available on crate features https
or nativetls
only.
pub fn https_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
https
or nativetls
only.Use client::https_default()
to build a client.
This is the same as Self::nativetls_default()
.
For the meaning of “authority”, refer to the documentation of Uri
.
The path
should implement PathRewriter
.
Source§impl<Pr, B> OneshotService<Pr, HttpsConnector<HttpConnector>, B>
impl<Pr, B> OneshotService<Pr, HttpsConnector<HttpConnector>, B>
Sourcepub fn nativetls_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
Available on crate feature nativetls
only.
pub fn nativetls_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
nativetls
only.Use client::nativetls_default()
to build a client.
For the meaning of “authority”, refer to the documentation of Uri
.
The path
should implement PathRewriter
.
Source§impl<Pr, B> OneshotService<Pr, RustlsConnector<HttpConnector>, B>
impl<Pr, B> OneshotService<Pr, RustlsConnector<HttpConnector>, B>
Sourcepub fn https_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
Available on crate feature rustls
only.
pub fn https_default<A>(authority: A, path: Pr) -> Result<Self, HttpError>
rustls
only.Use client::rustls_default()
to build a client.
For the meaning of “authority”, refer to the documentation of Uri
.
The path
should implement PathRewriter
.
Trait Implementations§
Source§impl<C, B, Pr> Service<Request<B>> for OneshotService<Pr, C, B>
impl<C, B, Pr> Service<Request<B>> for OneshotService<Pr, C, B>
Auto Trait Implementations§
impl<Pr, C = HttpConnector, B = Body> !Freeze for OneshotService<Pr, C, B>
impl<Pr, C = HttpConnector, B = Body> !RefUnwindSafe for OneshotService<Pr, C, B>
impl<Pr, C, B> Send for OneshotService<Pr, C, B>
impl<Pr, C, B> Sync for OneshotService<Pr, C, B>
impl<Pr, C, B> Unpin for OneshotService<Pr, C, B>
impl<Pr, C = HttpConnector, B = Body> !UnwindSafe for OneshotService<Pr, C, B>
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§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<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>
MakeService
, that will store C
’s
associated ConnectInfo
in a request extension such that ConnectInfo
can extract it. 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