Skip to main content

Crate zerodds_hpack

Crate zerodds_hpack 

Source
Expand description

Crate zerodds-hpack. Safety classification: STANDARD.

HPACK (RFC 7541) header-compression codec for HTTP/2 — no_std, forbid(unsafe_code). Implements the wire layer of variable-length integer coding (§5.1), string-literal coding (§5.2) including the static Huffman code (Appendix B), the static and dynamic table (§2.3, §4), as well as all four header-field representations (§6: Indexed / Literal-with-Indexing / Literal-without-Indexing / Literal-Never-Indexed).

Spec: RFC 7541 §5 (Primitive Type Representations) + §6 (Binary Format).

§Layer position

Layer 5 — Bridges. Substrate for:

§Public API (as of 1.0.0-rc.1)

§Example

use zerodds_hpack::{Decoder, Encoder, HeaderField};

let mut encoder = Encoder::new();
let mut decoder = Decoder::new();

let headers = vec![
    HeaderField { name: ":method".into(), value: "GET".into() },
    HeaderField { name: ":scheme".into(), value: "https".into() },
    HeaderField { name: "custom-key".into(), value: "custom-value".into() },
];

let wire = encoder.encode(&headers);
let decoded = decoder.decode(&wire).expect("roundtrip");
assert_eq!(decoded, headers);

Re-exports§

pub use decoder::Decoder;
pub use decoder::DecoderError;
pub use encoder::Encoder;
pub use encoder::EncoderError;
pub use integer::decode_integer;
pub use integer::encode_integer;
pub use string::decode_string;
pub use string::encode_string;
pub use table::HeaderField;
pub use table::STATIC_TABLE;
pub use table::StaticTableEntry;
pub use table::Table;

Modules§

decoder
HPACK Decoder — RFC 7541 §6.
encoder
HPACK Encoder — RFC 7541 §6.
huffman
RFC 7541 Appendix B Static Huffman Code.
integer
Variable-length integer coding — RFC 7541 §5.1.
string
String-literal coding — RFC 7541 §5.2.
table
HPACK static + dynamic table — RFC 7541 §2.3.