Skip to main content

Module error

Module error 

Source
Expand description

Why bytes were rejected, split by the direction that produced them.

  • DecodeError comes from bytes a peer sent. Exactly one variant, DecodeError::Incomplete, is not a violation: a head, a chunk line or a frame may be split across reads, and asking for more octets is the normal answer. DecodeError::is_violation says which is which, because the remedy differs: read again, or refuse the message.
  • EncodeError comes from our own side: a value the wire cannot carry, such as a field value holding a line feed, which a recipient would read as the start of another field. The encoders refuse rather than escape, because HTTP has no escaping mechanism for either.

The what of every variant names the rule that was broken in the words of the RFC, so a library above can map it onto a status code or an error code without parsing a message.

Enumsยง

DecodeError
Why bytes could not be decoded.
EncodeError
Why a value could not be encoded.