#[non_exhaustive]pub struct ConnContext {
pub id: ConnId,
pub remote: SocketAddr,
pub local: SocketAddr,
pub transport: Transport,
pub entered_at: Instant,
pub tls: Mutex<Option<TlsInfo>>,
pub http_version: OnceLock<HttpVersion>,
pub user: Mutex<Extensions>,
}Expand description
Per-connection state shared between the listener and the executor.
#[non_exhaustive] so downstream crates cannot construct a
ConnContext via a struct literal — the listener layer owns
construction. Existing field-access patterns (conn.id,
conn.tls.lock(), …) remain available to workspace crates so
the engine’s hot path stays unchanged; new code should prefer the
accessor methods below for the locked fields.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: ConnId§remote: SocketAddr§local: SocketAddr§transport: Transport§entered_at: Instant§tls: Mutex<Option<TlsInfo>>§http_version: OnceLock<HttpVersion>§user: Mutex<Extensions>Implementations§
Source§impl ConnContext
impl ConnContext
Sourcepub fn new(
id: ConnId,
remote: SocketAddr,
local: SocketAddr,
transport: Transport,
entered_at: Instant,
) -> Self
pub fn new( id: ConnId, remote: SocketAddr, local: SocketAddr, transport: Transport, entered_at: Instant, ) -> Self
Construct a fresh per-connection context. The TLS / user- extension mutexes and the http-version once-lock all start empty; the listener fills them as the handshake progresses.
#[non_exhaustive] on the struct blocks external struct
literals, so this constructor is the only public entry point
for building a ConnContext from outside vane-core.
Sourcepub fn tls(&self) -> MutexGuard<'_, Option<TlsInfo>>
pub fn tls(&self) -> MutexGuard<'_, Option<TlsInfo>>
Lock-and-read access to the TLS state. The returned guard is a
parking_lot::MutexGuard — drop it as soon as the read is
done to release the lock for other tasks.
Sourcepub fn with_user<R>(&self, f: impl FnOnce(&mut Extensions) -> R) -> R
pub fn with_user<R>(&self, f: impl FnOnce(&mut Extensions) -> R) -> R
Closure-scoped mutable access to the per-connection
extension map. Prefer this over directly grabbing
conn.user.lock() — the closure bound makes the lock window
visible at the call site, which matters because the executor
holds the same mutex across several dispatch arms.