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: RequestWriterRequest encoder (sans-IO). Build requests here.
reader: ResponseReaderResponse parser. Fed by the connection during send.
conn: Option<HttpConnection<MaybeTls>>Transport. None if connection died and needs reconnect.
Implementations§
Source§impl ClientSlot
impl ClientSlot
Sourcepub fn needs_reconnect(&self) -> bool
pub fn needs_reconnect(&self) -> bool
Whether the connection is dead and needs reconnect.
Sourcepub fn conn_and_reader(
&mut self,
) -> Result<(&mut HttpConnection<MaybeTls>, &mut ResponseReader), RestError>
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§
impl !Freeze for ClientSlot
impl !RefUnwindSafe for ClientSlot
impl Send for ClientSlot
impl Sync for ClientSlot
impl Unpin for ClientSlot
impl UnsafeUnpin for ClientSlot
impl !UnwindSafe for ClientSlot
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
Mutably borrows from an owned value. Read more