1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Dynamic-table-aware HPACK encoder (RFC 7541).
//!
//! Per-connection encoder owned by the H2 driver task. Each HEADERS block is encoded via
//! [`HpackEncoder::encode`] in a single synchronous pass at submission-pickup time. The
//! encoder is held by `&mut` on the driver — nothing else reaches it, so the table state
//! is just a plain field with no synchronization.
//!
//! ## Module layout
//!
//! - [`state`] — `TableState`, `insert`, FIFO eviction, reverse-index helpers.
//! - [`encode`] — the per-line decision walk and wire-format helpers.
use crateHeaderObserver;
use TableState;
use Arc;
/// Per-connection HPACK encoder.
///
/// Construct one per HTTP/2 connection (server or client). The dynamic table starts at
/// `min(local_preferred_size, 4096)`, the size a peer's decoder assumes until its SETTINGS
/// say otherwise; a peer that later advertises less must accept the larger size until its
/// SETTINGS are acknowledged, so encoding against the default from the first frame is safe.
/// When an explicit `SETTINGS_HEADER_TABLE_SIZE` arrives, [`Self::set_protocol_max_size`]
/// recomputes the size as `min(local_preferred_size, peer_advertised)` and, if it changed,
/// queues a Dynamic Table Size Update for the next encode call.
///
/// The cross-connection header observer is shared via `Arc` across all connections on a
/// listener; this encoder folds its per-connection observation accumulator into the
/// shared observer in [`Drop`].
pub