Struct Client
pub struct Client<C, B> { /* private fields */ }
A Client to make outgoing HTTP requests.
Client is cheap to clone and cloning is the recommended way to share a Client. The
underlying connection pool will be reused.
Implementations
impl Client<(), ()>
fn builder<E>(executor: E) -> Builder where E: Executor<Pin<Box<dyn Future<Output = ()> + Send>>> + Send + Sync + Clone + 'static,Create a builder to configure a new
Client.Example
# # #
impl<C, B> Client<C, B>
where
C: Connect + Clone + Send + Sync + 'static,
B: Body + Send + 'static + Unpin,
B::Data: Send,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
fn get(&self, uri: Uri) -> ResponseFuture where B: Default,Send a
GETrequest to the suppliedUri.Note
This requires that the
Bodytype have aDefaultimplementation. It should return an "empty" version of itself, such thatBody::is_end_streamistrue.Example
# # #fn request(&self, req: Request<B>) -> ResponseFutureSend a constructed
Requestusing thisClient.Example
# # #
Trait Implementations
impl<C, B> Debug for Client<C, B>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<C, B> Service<Request<B>> for Client<C, B>
where
C: Connect + Clone + Send + Sync + 'static,
B: Body + Send + 'static + Unpin,
B::Data: Send,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
type Response = Response<Incoming>;type Error = Error;type Future = ResponseFuture;fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, req: Request<B>) -> Self::Future
impl<C: Clone, B> Clone for Client<C, B>
fn clone(&self) -> Client<C, B>
Auto Trait Implementations
impl<C, B> !RefUnwindSafe for Client<C, B>
impl<C, B> !UnwindSafe for Client<C, B>
impl<C, B> Freeze for Client<C, B>
where
C: Freeze,
Pool<PoolClient<B>, (Scheme, Authority)>: Freeze,
impl<C, B> Send for Client<C, B>
where
C: Send,
Pool<PoolClient<B>, (Scheme, Authority)>: Send,
impl<C, B> Sync for Client<C, B>
where
C: Sync,
Pool<PoolClient<B>, (Scheme, Authority)>: Sync,
impl<C, B> Unpin for Client<C, B>
where
C: Unpin,
Pool<PoolClient<B>, (Scheme, Authority)>: Unpin,
impl<C, B> UnsafeUnpin for Client<C, B>
where
C: UnsafeUnpin,
Pool<PoolClient<B>, (Scheme, Authority)>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for Client<C, B>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Client<C, B>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Client<C, B>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Client<C, B>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Client<C, B>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Client<C, B>
impl<T> ToOwned for Client<C, B>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> WithSubscriber for Client<C, B>
impl<T, U> Into<U> for Client<C, B>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Client<C, B>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Client<C, B>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>