[][src]Crate rhymessage

This crate provides types for parsing and generating the headers of Internet messages, such as e-mail, HTTP requests or responses, and SIP messages. The typical format of these headers is described in IETF RFC 5322. Note that specific Internet standards may leverage this format but make exceptions, extensions, or other changes to it.

To parse a message, construct a MessageHeaders value using MessageHeaders::new, and then start feeding it input text via MessageHeaders::parse. Each call will consume zero or more of the input characters. Input is only consumed if enough is provided for the parser to determine when all of one or more headers has been provided. Any unused input should be included in the next call along with additional input to continue parsing. Parsing is complete once the message body is found.

To generate a message, construct a MessageHeaders value using MessageHeaders::new, fill in headers using MessageHeaders::add_header and other related functions, and emit the final text using MessageHeaders::generate.

By default, there is no constraint set on the lengths of header lines. This can cause issues in some places, such as servers receiving input from untrusted connections. An attacker might feed in a constant stream of characters that never includes a line ending, causing the server to exceed its memory allocation limits. To prevent this, the MessageHeaders::set_line_limit function can be used to set a constraint for header line length, both for parsing and generation.



This represents one line of the headers portion of an Internet message. It consists of a case-insensitive name and a value, which may contain parts separated by commas.


This is a newtype wrapping a String in order to handle it as an Internet message header name.


This type is used to parse and generate the headers of Internet messages, which consist of text lines, with an empty line separating the headers from the body. The format is specified in IETF RFC 5322.


This holds the values returned by MessageHeaders::parse.



This is the enumeration of all the different kinds of errors which this crate generates.


This enumerates the ways in which a multi-value header may be represented in the generated text.


This enumerates the possible non-error states MessageHeaders can be in after parsing a bit of input.