Skip to main content

PooledClient

Struct PooledClient 

Source
pub struct PooledClient<'a> { /* private fields */ }
Expand description

A pool-owned handle to an HttpClient.

Borrows the pool exclusively while alive; derefs to &mut HttpClient. On drop, the guard inspects HttpClient::peer_will_close and recycles its slot (closes the underlying connection and marks the slot for lazy reconnect) when the peer has signalled close — avoiding the request-smuggling-class hazard of sending a fresh request on a connection the server is about to close.

Implementations§

Source§

impl PooledClient<'_>

Source

pub fn slot(&self) -> usize

Index of the underlying slot in the pool. Useful for callers that want to explicitly recycle (e.g., on an application-level error the guard’s peer_will_close check would not catch).

Methods from Deref<Target = HttpClient>§

Source

pub fn get(&mut self, path: &str) -> RequestBuilder<'_>

Build a GET request.

Source

pub fn post(&mut self, path: &str) -> RequestBuilder<'_>

Build a POST request.

Source

pub fn put(&mut self, path: &str) -> RequestBuilder<'_>

Build a PUT request.

Source

pub fn delete(&mut self, path: &str) -> RequestBuilder<'_>

Build a DELETE request.

Source

pub fn close(&self)

Close the underlying connection.

Source

pub fn peer_will_close(&self) -> bool

Whether the peer has signalled the connection will close. For H1 this reflects Connection: close on the most recent response (or the HTTP/1.0 default); for H2 this reflects a GOAWAY frame. The Pool honours this automatically via the guard returned by Pool::client.

Trait Implementations§

Source§

impl Deref for PooledClient<'_>

Source§

type Target = HttpClient

The resulting type after dereferencing.
Source§

fn deref(&self) -> &HttpClient

Dereferences the value.
Source§

impl DerefMut for PooledClient<'_>

Source§

fn deref_mut(&mut self) -> &mut HttpClient

Mutably dereferences the value.
Source§

impl Drop for PooledClient<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PooledClient<'a>

§

impl<'a> !UnwindSafe for PooledClient<'a>

§

impl<'a> Freeze for PooledClient<'a>

§

impl<'a> Send for PooledClient<'a>

§

impl<'a> Sync for PooledClient<'a>

§

impl<'a> Unpin for PooledClient<'a>

§

impl<'a> UnsafeUnpin for PooledClient<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.