[−][src]Struct rhymessage::MessageHeaders
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.
Implementations
impl MessageHeaders
[src]
pub fn add_header<N, V>(&mut self, name: N, value: V) where
N: Into<HeaderName>,
V: Into<String>,
[src]
N: Into<HeaderName>,
V: Into<String>,
Append a header with the given name and value. This does not change or
remove any previously added headers, even if they have the same name.
To replace a previously added header, use
set_header
instead.
pub fn add_header_multi_value<N, V>(
&mut self,
name: N,
values: V,
mode: HeaderMultiMode
) where
N: AsRef<str>,
V: Into<Vec<String>>,
[src]
&mut self,
name: N,
values: V,
mode: HeaderMultiMode
) where
N: AsRef<str>,
V: Into<Vec<String>>,
Append one or more headers with the given name and values derived from
the given vector, depending on the given mode (see
HeaderMultiMode
for more information).
This does not change or remove any previously added headers, even if
they have the same name. To replace a previously added header, use
set_header_multi_value
instead.
pub fn generate(&self) -> Result<String, Error>
[src]
Produce the text string form of the message, according to the rules of RFC 5322:
- Each header is separated by a carriage-return line-feed sequence (CRLF).
- Headers may be folded onto multiple lines at whitespace characters (which are strictly space ('\x20') and horizontal tab ('\x09').
- The first line of a header consists of the header name followed by a colon (':') followed by a space ('\x20') followed by part or all of the header value.
- After all headers, an empty line is placed to mark where the body begins.
Errors
Error::HeaderLineCouldNotBeFolded
is returned if the generator
is configured with a line limit constraint and one or more headers
are too long and cannot be folded to fit within the constraint.
While technically it shouldn't happen, logically we may return
Error::StringFormat
if one of the internal string formatting
functions should fail (which they shouldn't unless something
used internally doesn't implement Display
properly.
#[must_use]pub fn headers(&self) -> &Vec<Header>
[src]
Borrow the list of headers.
#[must_use]pub fn header_multi_value<T>(&self, name: T) -> Vec<String> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Produce a list of the values for the headers with the given name. If no headers have the given name, an empty list is returned.
#[must_use]pub fn header_tokens<T>(&self, name: T) -> Vec<String> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Take the value of the header with the given name, interpret it as a comma-separated list of values, and produce that list. If no headers have the given name, an empty list is returned.
#[must_use]pub fn header_value<T>(&self, name: T) -> Option<String> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Produce the value for the header with the given name, if any. If there are two or more headers with the same name, the produced string will be the joining of their values with commas.
pub fn has_header_token<T>(&self, name: T, token: T) -> bool where
T: AsRef<str>,
[src]
T: AsRef<str>,
This is a convenience function which essentially looks up the tokens
in a header using header_tokens
and searches them to see if the given token is among them.
#[must_use]pub fn has_header<T>(&self, name: T) -> bool where
T: AsRef<str>,
[src]
T: AsRef<str>,
Determine whether or not the given header is present.
#[must_use]pub fn new() -> Self
[src]
Create a new instance with no headers in it.
pub fn parse<T>(&mut self, raw_message: T) -> Result<ParseStatus, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Feed more Internet message text into the parser, building the collection of headers internally, and detecting when the end of the headers and the beginning of the body is found.
See ParseStatus
for details on what
this function returns to indicate the result of the parsing.
Errors
HeaderLineTooLong
&nash; the parser is configured with a line length constraint and the input exceeds it on a lineHeaderLineMissingColon
– there is no colon between the name and value of a header lineHeaderNameContainsIllegalCharacter
– the name of a header contains an illegal characterHeaderValueContainsIllegalCharacter
– the value of a header contains an illegal character
pub fn remove_header<N>(&mut self, name: N) where
N: AsRef<str>,
[src]
N: AsRef<str>,
Remove all headers with the given name.
pub fn set_header<N, V>(&mut self, name: N, value: V) where
N: AsRef<str>,
V: Into<String>,
[src]
N: AsRef<str>,
V: Into<String>,
Add or replace a header with the given name and value. If one or more
previously added headers has the same name, the first one is changed to
hold the given value, and the others are removed. To add a new header
without replacing or removing previously added ones with the same name,
use add_header
instead.
pub fn set_header_multi_value<N, V>(
&mut self,
name: N,
values: V,
mode: HeaderMultiMode
) where
N: AsRef<str>,
V: Into<Vec<String>>,
[src]
&mut self,
name: N,
values: V,
mode: HeaderMultiMode
) where
N: AsRef<str>,
V: Into<Vec<String>>,
Add or replace one or more headers with the given name and values
derived from the given vector, depending on the given mode (see
HeaderMultiMode
for more information).
If one or more previously added headers has the same name, the first
one is changed to hold the given value(s), and the others are removed.
To add new headers without replacing or removing previously added ones
with the same name, use
add_header_multi_value
instead.
pub fn set_line_limit(&mut self, limit: Option<usize>)
[src]
This configures the parser and generator to constrain the lengths
of header lines to no more than the given number, if any. Setting
None
removes any constraint.
Trait Implementations
impl Clone for MessageHeaders
[src]
fn clone(&self) -> MessageHeaders
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MessageHeaders
[src]
impl Default for MessageHeaders
[src]
fn default() -> MessageHeaders
[src]
Auto Trait Implementations
impl RefUnwindSafe for MessageHeaders
impl Send for MessageHeaders
impl Sync for MessageHeaders
impl Unpin for MessageHeaders
impl UnwindSafe for MessageHeaders
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,