pub enum NetworkStream {
Upgraded(UpgradedStream),
Metadata(Arc<ConnectionMetadata>),
}Expand description
A network stream handle exposed on responses for metadata access.
For upgraded connections (101/CONNECT), this provides full read/write/close/TLS access. For ordinary pooled connections, this provides read-only metadata — raw IO operations are not exposed while Hyper still owns the connection.
§Ordinal response limitation
Hyper’s legacy client pool retains ownership of socket connections
for ordinary HTTP/1.1 and HTTP/2 responses. The pool does not expose
per-response socket metadata, and raw IO operations would corrupt
pool state. Therefore, NetworkStream::Metadata is currently only
constructed for responses where socket metadata can be safely
captured without interfering with the pool. For ordinary responses,
network_stream on Response is None.
This is a documented bounded difference from httpcore, which owns its connections directly and can expose metadata on every response.
Variants§
Upgraded(UpgradedStream)
An upgraded stream with full IO access.
Metadata(Arc<ConnectionMetadata>)
Read-only metadata for an ordinary pooled connection.
Currently reserved for future use when socket metadata can be
safely captured from Hyper’s connection pool. For ordinary
responses, Response::network_stream() returns None.
Implementations§
Source§impl NetworkStream
impl NetworkStream
Sourcepub fn metadata(&self) -> &Arc<ConnectionMetadata> ⓘ
pub fn metadata(&self) -> &Arc<ConnectionMetadata> ⓘ
Returns the connection metadata.
Sourcepub fn is_upgraded(&self) -> bool
pub fn is_upgraded(&self) -> bool
Returns true if this is an upgraded stream with IO access.
Sourcepub fn as_upgraded(&self) -> Option<&UpgradedStream>
pub fn as_upgraded(&self) -> Option<&UpgradedStream>
If this is an upgraded stream, returns a reference to it.
Sourcepub fn as_upgraded_mut(&mut self) -> Option<&mut UpgradedStream>
pub fn as_upgraded_mut(&mut self) -> Option<&mut UpgradedStream>
If this is an upgraded stream, returns a mutable reference.
Sourcepub fn into_upgraded(self) -> Option<UpgradedStream>
pub fn into_upgraded(self) -> Option<UpgradedStream>
If this is an upgraded stream, consume and return it.