[−][src]Struct email::rfc5322::Rfc5322Parser
RFC 5322 base parser for parsing
atom
, dot-atom
, quoted-string
, phrase
, message
This should prove useful for parsing other things that appear in RFC 5322, as most are based off these core items.
It also implements a stack for tracking the position. This allows the simple implementation of backtracking, by pushing the position before a test and popping it if the test should fail. [unstable]
Methods
impl<'s> Rfc5322Parser<'s>
[src]
pub fn new(source: &'s str) -> Rfc5322Parser<'s>
[src]
Make a new parser, initialized with the given string. [unstable]
pub fn push_position(&mut self)
[src]
Push the current position onto the stack. [unstable]
pub fn pop_position(&mut self)
[src]
Move the position back to the last entry pushed [unstable]
pub fn consume_message(&mut self) -> Option<(HeaderMap, String)>
[src]
Consume a message from the input.
Returns as a map of the headers and the body text.
A message is defined as:
fields = *field body = text message = fields CRLF body
[unstable]
pub fn consume_header(&mut self) -> Option<Header>
[src]
Consume a header from the input.
A header is defined as:
ftext = "!".."9" / ";".."~" field-name = 1*ftext field = field-name *LWSP ":" unstructured
[unstable]
pub fn consume_unstructured(&mut self) -> String
[src]
Consume an unstructured from the input. [unstable]
pub fn consume_folding_whitespace(&mut self) -> bool
[src]
Consume folding whitespace.
This is a CRLF followed by one or more whitespace character.
Returns true if whitespace was consume [unstable]
pub fn consume_word(&mut self, allow_dot_atom: bool) -> Option<String>
[src]
Consume a word from the input.
A word is defined as:
word = atom / quoted-string
If allow_dot_atom
is true, then atom
can be a dot-atom
in this phrase.
[unstable]
pub fn consume_phrase(&mut self, allow_dot_atom: bool) -> Option<String>
[src]
Consume a phrase from the input.
A phrase is defined as:
phrase = 1*word
If allow_dot_atom
is true, then atom
can be a dot-atom
in this phrase.
[unstable]
pub fn consume_quoted_string(&mut self) -> Option<String>
[src]
Consume a quoted string from the input [unstable]
pub fn consume_atom(&mut self, allow_dot: bool) -> Option<String>
[src]
Consume an atom from the input.
If allow_dot
is true, then also allow '.' to be considered as an
atext character.
[unstable]
pub fn consume_linear_whitespace(&mut self)
[src]
Consume LWSP (Linear whitespace) [unstable]
pub fn consume_char(&mut self) -> Option<char>
[src]
Consume a single character from the input. [unstable]
pub fn consume_linebreak(&mut self) -> bool
[src]
[unstable]
pub fn peek_linebreak(&mut self) -> bool
[src]
[unstable]
pub fn consume_while<F: Fn(char) -> bool>(&mut self, test: F) -> String
[src]
Consume a set of characters, each passed to test
until this function
returns false.
The position after calling this function will be pointing to the character
which caused a false result from test
.
Returns the string of characters that returned true for the test function. [unstable]
pub fn peek(&self) -> char
[src]
Peek at the current character.
Note that this does not do any bounds checking. [unstable]
pub fn assert_char(&self, c: char) -> ParsingResult<()>
[src]
Check that !self.eof() && self.peek() == c
[unstable]
pub fn assert_not_eof(&self) -> ParsingResult<()>
[src]
Check that we have not reached the end of the input. [unstable]
pub fn peek_to_end(&self) -> &str
[src]
Get the unconsumed string. Should only be used for debugging purposes! [unstable]
pub fn eof(&self) -> bool
[src]
Returns true if we have reached the end of the input. [unstable]
Auto Trait Implementations
impl<'s> RefUnwindSafe for Rfc5322Parser<'s>
impl<'s> Send for Rfc5322Parser<'s>
impl<'s> Sync for Rfc5322Parser<'s>
impl<'s> Unpin for Rfc5322Parser<'s>
impl<'s> UnwindSafe for Rfc5322Parser<'s>
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, 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,