silk.http.http2_connection.
HTTP/2 over the existing plain or TLS HttpTransport service.
Create a Driver, queue requests or responses through Driver.connection, and call
Driver.next to flush output and receive an event. Calls preserve unread bytes between events.
The provider remains caller-owned. Use silk.http.transport.plain for a socket or
silk.http.transport.secured after a TLS handshake with required h2 ALPN.
Import as Driver with import silk.http.http2_connection { Driver }.
Public declarations: 3.
protocol#
pub fn protocol() -> AlpnProtocol<'static>Returns the h2 ALPN identifier. Offer it with AlpnConfig.Offered and required: true for HTTP/2-only TLS.
requireAlpn#
pub effect fn requireAlpn(authentication: &Authentication) -> ()
! ProtocolErrorVerifies that an authenticated TLS connection selected h2. Other protocols fail with PROTOCOL_ERROR.
Driver#
pub struct DriverA buffered driver for one HTTP/2 connection. It borrows the transport through the Effect service.
Implementation Driver#
impl DriverAssociated function make#
pub effect fn make(endpoint: Role, limits: Limits) -> Driver
! ProtocolError | OutOfMemoryError
? &mut AllocatorCreates a protocol connection and a 16 KiB transport read buffer. No I/O occurs until flush or next.
Method connection#
pub fn connection(self: &mut Self) -> &mut ConnectionBorrows the protocol connection to open streams, send fields or data, return credit, or initiate shutdown.
Method flush#
pub effect fn flush(self: &mut Self, deadline: Option<Instant>) -> ()
! ProtocolError | TransportError | OutOfMemoryError
? &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut RandomSends all queued protocol bytes and flushes the transport with the caller's absolute deadline.
Method close#
pub effect fn close(self: &mut Self, deadline: Option<Instant>, drainBytes: usize) -> ()
! ProtocolError | TransportError | OutOfMemoryError
? &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut RandomFlushes output, drains at most drainBytes incoming bytes, and closes the transport.
Give a finite deadline after GOAWAY so unread socket data does not discard the shutdown frame.
Drain failures stop draining. Flush and close failures are returned after the close attempt.
Method next#
pub effect fn next(self: &mut Self, deadline: Option<Instant>) -> Option<Event>
! ProtocolError | TransportError | OutOfMemoryError
? &mut HttpTransport | &mut MonotonicClock | &mut Allocator | &mut RandomFlushes queued output, then waits for one event. None means clean transport EOF. A partial frame or unfinished stream at EOF fails. Protocol errors attempt to flush GOAWAY before returning.
Category: HTTP.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.