pub struct DynHttpClient { /* private fields */ }Expand description
A type-erased, cheaply cloneable HTTP transport.
Clones share the transport and middleware instances but copy the middleware
list. Erasing an already erased transport clones it without another layer.
Debug prints only the type name to avoid exposing transport credentials.
The transport is not serializable.
fn assert_serialize<T: serde::Serialize>() {}
assert_serialize::<rig_http::http_client::DynHttpClient>();Implementations§
Source§impl DynHttpClient
impl DynHttpClient
Sourcepub fn new<H>(http: H) -> DynHttpClientwhere
H: HttpClientExt + 'static,
pub fn new<H>(http: H) -> DynHttpClientwhere
H: HttpClientExt + 'static,
Erase http. If http is already a DynHttpClient, this is a clone
(its attached middleware included).
Sourcepub fn with_middleware<M>(self, middleware: M) -> DynHttpClientwhere
M: HttpMiddleware + 'static,
pub fn with_middleware<M>(self, middleware: M) -> DynHttpClientwhere
M: HttpMiddleware + 'static,
Attach a transport-boundary HttpMiddleware to this handle.
Hooks run in attachment order with the phases defined by HttpMiddleware.
Existing clones keep their previous stack. The underlying transport stays
shared, so Self::ptr_eq is unaffected.
Sourcepub fn ptr_eq(&self, other: &DynHttpClient) -> bool
pub fn ptr_eq(&self, other: &DynHttpClient) -> bool
Whether two handles share the same underlying transport.
Compares the transport only: handles that differ in attached middleware but wrap the same transport still compare equal.
Trait Implementations§
Source§impl Clone for DynHttpClient
impl Clone for DynHttpClient
Source§fn clone(&self) -> DynHttpClient
fn clone(&self) -> DynHttpClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DynHttpClient
impl Debug for DynHttpClient
Source§impl HttpClientExt for DynHttpClient
impl HttpClientExt for DynHttpClient
Source§fn send<T, U>(
&self,
req: Request<T>,
) -> impl Future<Output = Result<Response<Pin<Box<dyn Future<Output = Result<U, Error>> + Send>>>, Error>> + WasmCompatSend + 'static
fn send<T, U>( &self, req: Request<T>, ) -> impl Future<Output = Result<Response<Pin<Box<dyn Future<Output = Result<U, Error>> + Send>>>, Error>> + WasmCompatSend + 'static
U.Source§fn send_multipart<U>(
&self,
req: Request<MultipartForm>,
) -> impl Future<Output = Result<Response<Pin<Box<dyn Future<Output = Result<U, Error>> + Send>>>, Error>> + WasmCompatSend + 'static
fn send_multipart<U>( &self, req: Request<MultipartForm>, ) -> impl Future<Output = Result<Response<Pin<Box<dyn Future<Output = Result<U, Error>> + Send>>>, Error>> + WasmCompatSend + 'static
U.Auto Trait Implementations§
impl !RefUnwindSafe for DynHttpClient
impl !UnwindSafe for DynHttpClient
impl Freeze for DynHttpClient
impl Send for DynHttpClient
impl Sync for DynHttpClient
impl Unpin for DynHttpClient
impl UnsafeUnpin for DynHttpClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more