[−][src]Enum rhymessage::ParseStatus
This enumerates the possible non-error states MessageHeaders
can be in
after parsing a bit of input.
Examples
use rhymessage::{MessageHeaders, ParseStatus}; let mut headers = MessageHeaders::new(); // `parse` does not consume first line because the next line // it hasn't seen yet might contain part of the "From" header. assert_eq!( ParseStatus::Incomplete(0), headers.parse("From: joe@example.com\r\n")? ); // So we re-send the "From" line along with the content that follows. // At this point, `parse` knows it has the full "From" header, and // consumes it, but not the "To" header, since the next line might // be a continuation of it. assert_eq!( ParseStatus::Incomplete(23), headers.parse(concat!( "From: joe@example.com\r\n", "To: sal@example.com\r\n", ))? ); // So we re-send the "To" line along with the content that follows. // At this point, `parse` knows it has the full "To" header, and // consumes it, but not the "Subject" header, since the next line might // be a continuation of it. assert_eq!( ParseStatus::Incomplete(21), headers.parse(concat!( "To: sal@example.com\r\n", "Subject: Hello,\r\n", ))? ); // So we re-send the "Subject" line along with the content that // follows. At this point, `parse` still doesn't know it has the // full "Subject" header, so nothing is consumed. assert_eq!( ParseStatus::Incomplete(0), headers.parse(concat!( "Subject: Hello,\r\n", " World!\r\n", ))? ); // So we re-send again with even more content. At this point, // `parse` sees the empty line separating headers from body, // so it can finally consume the "Subject" header as well as // indicate that parsing the headers is complete. assert_eq!( ParseStatus::Complete(28), headers.parse(concat!( "Subject: Hello,\r\n", " World!\r\n", "\r\n", ))? );
Variants
Complete(usize)
The body was found at the attached byte offset in the last input string.
Incomplete(usize)
The body was not found, but all characters up to but not including the attached byte offset were parsed.
The user is expected to call parse
again with more input, starting
with the unparsed portion of the previous input string, and adding more
to it.
Trait Implementations
impl Debug for ParseStatus
[src]
impl Eq for ParseStatus
[src]
impl PartialEq<ParseStatus> for ParseStatus
[src]
fn eq(&self, other: &ParseStatus) -> bool
[src]
fn ne(&self, other: &ParseStatus) -> bool
[src]
impl StructuralEq for ParseStatus
[src]
impl StructuralPartialEq for ParseStatus
[src]
Auto Trait Implementations
impl RefUnwindSafe for ParseStatus
impl Send for ParseStatus
impl Sync for ParseStatus
impl Unpin for ParseStatus
impl UnwindSafe for ParseStatus
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>,