Skip to main content

ringline_h2/
lib.rs

1//! Sans-IO HTTP/2 client framing layer.
2//!
3//! This crate provides a pure sans-IO HTTP/2 client framing layer. It has
4//! zero runtime dependencies -- the caller feeds bytes in via `recv()` and
5//! pulls bytes out via `take_pending_send()`.
6//!
7//! # Architecture
8//!
9//! ```text
10//!   TCP + TLS bytes
11//!        |
12//!   +----v----------+
13//!   | ringline-h2   |  HTTP/2 framing + HPACK
14//!   | H2Connection  |  H2Event: Response, Data, Trailers, etc.
15//!   +---------------+
16//! ```
17//!
18//! # Example
19//!
20//! ```rust,ignore
21//! use ringline_h2::{H2Connection, H2Event, HeaderField, Settings};
22//!
23//! let mut h2 = H2Connection::new(Settings::client_default());
24//!
25//! // Send the connection preface to the transport.
26//! let preface = h2.take_pending_send();
27//! transport_send(&preface);
28//!
29//! // Send a GET request.
30//! let stream_id = h2.send_request(&[
31//!     HeaderField::new(b":method", b"GET"),
32//!     HeaderField::new(b":path", b"/"),
33//!     HeaderField::new(b":scheme", b"https"),
34//!     HeaderField::new(b":authority", b"example.com"),
35//! ], true)?;
36//! transport_send(&h2.take_pending_send());
37//!
38//! // Feed received bytes.
39//! h2.recv(&received_data)?;
40//!
41//! // Drain events.
42//! while let Some(event) = h2.poll_event() {
43//!     match event {
44//!         H2Event::Response { stream_id, headers, end_stream } => { /* ... */ }
45//!         H2Event::Data { stream_id, data, end_stream } => { /* ... */ }
46//!         _ => {}
47//!     }
48//! }
49//! ```
50
51pub mod connection;
52pub mod error;
53pub mod flowcontrol;
54pub mod frame;
55pub mod hpack;
56mod huffman;
57pub mod settings;
58mod stream;
59
60pub use connection::{H2Connection, H2Event};
61pub use error::{ErrorCode, H2Error};
62pub use frame::Frame;
63pub use hpack::HeaderField;
64pub use settings::Settings;