Skip to main content

ClientSlot

Struct ClientSlot 

Source
pub struct ClientSlot {
    pub writer: RequestWriter,
    pub reader: ResponseReader,
    pub conn: Option<HttpConnection<MaybeTls>>,
}
Expand description

A complete request/response pipeline: writer + reader + transport.

Each slot in the pool owns its own set of protocol primitives. Acquired via ClientPool::acquire, auto-returned on drop.

Fields are public for split borrows through Pooled<T>’s DerefMut. Deref explicitly to split, then build + send:

let s: &mut ClientSlot = &mut slot;  // explicit deref, enables split borrows
let req = s.writer.post("/order").body(json).finish()?;
let (conn, reader) = (s.conn.as_mut().unwrap(), &mut s.reader);

// With timeout (recommended for production):
let resp = tokio::time::timeout(timeout, conn.send(req, reader)).await??;

// Without timeout (prototyping only):
let resp = conn.send(req, reader).await?;

Fields§

§writer: RequestWriter

Request encoder (sans-IO). Build requests here.

§reader: ResponseReader

Response parser. Fed by the connection during send.

§conn: Option<HttpConnection<MaybeTls>>

Transport. None if connection died and needs reconnect.

Implementations§

Source§

impl ClientSlot

Source

pub fn needs_reconnect(&self) -> bool

Whether the connection is dead and needs reconnect.

Source

pub fn conn_and_reader( &mut self, ) -> Result<(&mut HttpConnection<MaybeTls>, &mut ResponseReader), RestError>

Split borrow: get mutable references to conn + reader while writer is borrowed by a Request<'_>.

This exists because Pooled<ClientSlot> goes through DerefMut which prevents the compiler from seeing disjoint field borrows.

Auto Trait Implementations§

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<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V