pub enum HttpConnection {
Http1(Arc<Mutex<Encryption>>),
Http2(Box<Connection<Encryption, Bytes>>),
Http3(Connection<Connection, Bytes>),
}
Expand description
A single HTTP connection.
See HttpConnection::new
on how to make one and
HttpConnection::accept
on getting a FatRequest
.
Variants§
Http1(Arc<Mutex<Encryption>>)
An HTTP/1 connection
Http2(Box<Connection<Encryption, Bytes>>)
Available on crate feature
http2
only.An HTTP/2 connection
This is boxed because a [h2::server::Connection
] takes up
over 1000 bytes of memory, and an Arc
8 bytes.
It will increase performance on servers with both HTTP/1 and HTTP/2
connections, but slightly hurt exclusively HTTP/2 servers.
We’ll see how we move forward once HTTP/3 support lands.
Http3(Connection<Connection, Bytes>)
Available on crate feature
http3
only.An HTTP/3 conenction.
Implementations§
source§impl HttpConnection
impl HttpConnection
sourcepub async fn new(stream: Encryption, version: Version) -> Result<Self, Error>
pub async fn new(stream: Encryption, version: Version) -> Result<Self, Error>
Creates a new HttpConnection
from an Encryption
stream.
§Errors
Returns Error::VersionNotSupported
when a unsupported version is passed.
Also passes errors from [h2::server::handshake
].
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HttpConnection
impl !RefUnwindSafe for HttpConnection
impl !Send for HttpConnection
impl !Sync for HttpConnection
impl Unpin for HttpConnection
impl !UnwindSafe for HttpConnection
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