pub struct SessionIo<'a> { /* private fields */ }Expand description
Handler-facing control surface for one session.
The handler uses this to respond, relay, dial upstreams, and manage the
session lifecycle. Buffer management is automatic: writes copy into
pre-allocated pool slots (one user-space copy, zero malloc).
Implementations§
Source§impl<'a> SessionIo<'a>
impl<'a> SessionIo<'a>
Sourcepub fn slot_index(&self) -> u32
pub fn slot_index(&self) -> u32
Session slot index (metrics/log correlation).
Sourcepub fn respond(&mut self, bytes: &[u8])
pub fn respond(&mut self, bytes: &[u8])
Queues bytes to the downstream socket.
§Panics
Never panics; on pool exhaustion the write is queued as pending
bytes (bounded by max_buffered — beyond that the session is
killed as runaway).
Sourcepub fn write_upstream(&mut self, bytes: &[u8])
pub fn write_upstream(&mut self, bytes: &[u8])
Queues bytes to the upstream socket (must be connected).
Sourcepub fn connect_upstream(&mut self, addr: SocketAddr) -> bool
pub fn connect_upstream(&mut self, addr: SocketAddr) -> bool
Dials a TCP upstream for this session.
Returns false when the connect could not even start; the
completion arrives via Handler::on_upstream_connected or
Handler::on_upstream_error.
Sourcepub fn connect_upstream_unix(&mut self, path: PathBuf) -> bool
pub fn connect_upstream_unix(&mut self, path: PathBuf) -> bool
Dials a Unix-domain-socket upstream.
Sourcepub fn start_splice(&mut self) -> bool
pub fn start_splice(&mut self) -> bool
Starts the zero-copy L4 splice pump (requires a connected upstream).
Sourcepub fn downstream_eof_write(&mut self)
pub fn downstream_eof_write(&mut self)
Half-closes the downstream write side (streaming completion).
Sourcepub fn upstream_eof_write(&mut self)
pub fn upstream_eof_write(&mut self)
Half-closes the upstream write side (end of request body).
Sourcepub fn set_deadline(&mut self, at: Option<Instant>, reason: DeadlineReason)
pub fn set_deadline(&mut self, at: Option<Instant>, reason: DeadlineReason)
Arms (or clears) the session’s single deadline slot with a reason.
Sourcepub fn detach_upstream(&mut self) -> Option<RawFd>
pub fn detach_upstream(&mut self) -> Option<RawFd>
Detaches the upstream fd without closing it (connection pooling). Returns the raw descriptor; the caller owns it from here.
Sourcepub fn discard_upstream(&mut self)
pub fn discard_upstream(&mut self)
Discards a dead upstream (close + epoch bump) so stale completions for its descriptor can never touch the session again.
Sourcepub fn attach_upstream(&mut self, fd: RawFd) -> bool
pub fn attach_upstream(&mut self, fd: RawFd) -> bool
Attaches a previously detached fd as this session’s upstream (connection pooling checkout) and arms its read.
Sourcepub fn upstream_fd(&self) -> Option<RawFd>
pub fn upstream_fd(&self) -> Option<RawFd>
Raw upstream descriptor (diagnostics).
Sourcepub fn request_sent_upstream(&self) -> bool
pub fn request_sent_upstream(&self) -> bool
true once the request head has been written to the upstream
(failover decisions must not re-send after this point).
Sourcepub fn mark_request_sent(&mut self)
pub fn mark_request_sent(&mut self)
Marks the request head as written upstream.
Sourcepub fn peer(&self) -> Option<SocketAddr>
pub fn peer(&self) -> Option<SocketAddr>
Peer address of the downstream connection.
Sourcepub fn has_upstream(&self) -> bool
pub fn has_upstream(&self) -> bool
true when the session has a connected upstream.