pub struct Violation { /* private fields */ }Expand description
Something the peer did that RFC 9114 (or 9204, or 9297) forbids.
Carries both halves of the answer the RFC prescribes: the error code to send, and whether the rule makes it a connection error rather than a stream one. Keeping the second half here rather than at the handling site is what stops the two from drifting apart — the same violation reported from a request stream and from the control stream must end the same thing either way.
Implementations§
Source§impl Violation
impl Violation
Sourcepub fn stream(code: Code, detail: impl Into<Cow<'static, str>>) -> Self
pub fn stream(code: Code, detail: impl Into<Cow<'static, str>>) -> Self
A violation of a rule that only ends the stream it happened on.
Sourcepub fn connection(code: Code, detail: impl Into<Cow<'static, str>>) -> Self
pub fn connection(code: Code, detail: impl Into<Cow<'static, str>>) -> Self
A violation of a rule the RFC states as a connection error.
Sourcepub fn field_section_too_large(detail: impl Into<Cow<'static, str>>) -> Self
pub fn field_section_too_large(detail: impl Into<Cow<'static, str>>) -> Self
An H3_EXCESSIVE_LOAD stream error a 431 is the right answer to.
The 431 (Request Header Fields Too Large) that
crate::h3::stream::Resolver::resolve sends is a diagnosis, not a
consequence of the code: it tells a peer which part of its request to
shrink (RFC 9114 §10.5.1). That is worth saying only when the fault
really is a field section too large to hold – the three sources being
the per-frame buffering limit, the advertised
SETTINGS_MAX_FIELD_SECTION_SIZE, and D77’s connection-wide budget.
It is stated here rather than inferred at the answering site because
H3_EXCESSIVE_LOAD is a code, not a class: RFC 9114 §10.5’s
reserved-frame flood carries the same code and no header field was ever
sent, so a peer told to shrink its field sections would be told to fix
something it never did. Marking the three that mean it keeps a fourth
source, added later, on the bare reset that is safe for anything.
Sourcepub fn is_connection_error(&self) -> bool
pub fn is_connection_error(&self) -> bool
Whether the whole connection has to be closed.
Sourcepub fn is_field_section_too_large(&self) -> bool
pub fn is_field_section_too_large(&self) -> bool
Whether a 431 is the right thing to tell the peer about this.
True only for Self::field_section_too_large, which says why. The one
reader is crate::h3::stream::Resolver::resolve; every other
stream-class violation, this code included, is answered by the bare reset
that says nothing a peer could act on wrongly.