Trait gmime::ParserExt [−][src]
pub trait ParserExt { fn construct_message<'a, P: Into<Option<&'a ParserOptions>>>(
&self,
options: P
) -> Option<Message>; fn construct_part<'a, P: Into<Option<&'a ParserOptions>>>(
&self,
options: P
) -> Option<Object>; fn eos(&self) -> bool; fn get_format(&self) -> Format; fn get_headers_begin(&self) -> i64; fn get_headers_end(&self) -> i64; fn get_mbox_marker(&self) -> Option<String>; fn get_mbox_marker_offset(&self) -> i64; fn get_persist_stream(&self) -> bool; fn get_respect_content_length(&self) -> bool; fn init_with_stream<P: IsA<Stream>>(&self, stream: &P); fn set_format(&self, format: Format); fn set_persist_stream(&self, persist: bool); fn set_respect_content_length(&self, respect_content_length: bool); fn tell(&self) -> i64; }
Required Methods
fn construct_message<'a, P: Into<Option<&'a ParserOptions>>>(
&self,
options: P
) -> Option<Message>
&self,
options: P
) -> Option<Message>
Constructs a MIME message from self
.
options
a ParserOptions
or None
Returns
a MIME message or None
on fail.
fn construct_part<'a, P: Into<Option<&'a ParserOptions>>>(
&self,
options: P
) -> Option<Object>
&self,
options: P
) -> Option<Object>
Constructs a MIME part from self
.
options
a ParserOptions
or None
Returns
a MIME part based on self
or None
on
fail.
fn eos(&self) -> bool
Tests the end-of-stream indicator for self
's internal stream.
Returns
true
on EOS or false
otherwise.
fn get_format(&self) -> Format
Gets the format that the parser is set to parse.
Returns
the format that the parser is set to parse.
fn get_headers_begin(&self) -> i64
Gets the stream offset of the beginning of the headers of the most recently parsed message.
Returns
the offset of the beginning of the headers of the most recently parsed message or %-1 on error.
fn get_headers_end(&self) -> i64
Gets the stream offset of the end of the headers of the most recently parsed message.
Returns
the offset of the end of the headers of the most recently parsed message or %-1 on error.
fn get_mbox_marker(&self) -> Option<String>
Gets the mbox-style From-line of the most recently parsed message
(gotten from ParserExt::construct_message
).
Returns
the mbox-style From-line of the most recently parsed
message or None
on error.
fn get_mbox_marker_offset(&self) -> i64
Gets the offset of the most recently parsed mbox-style From-line
(gotten from ParserExt::construct_message
).
Returns
the offset of the most recently parsed mbox-style From-line or %-1 on error.
fn get_persist_stream(&self) -> bool
Gets whether or not the underlying stream is persistent.
Returns
true
if the self
will leave the content on disk or
false
if it will load the content into memory.
fn get_respect_content_length(&self) -> bool
Gets whether or not self
is set to use Content-Length for
determining the offset of the end of the message.
Returns
whether or not self
is set to use Content-Length for
determining the offset of the end of the message.
fn init_with_stream<P: IsA<Stream>>(&self, stream: &P)
Initializes self
to use stream
.
WARNING: Initializing a parser with a stream is comparable to
selling your soul (stream
) to the devil (self
). You are
basically giving the parser complete control of the stream, this
means that you had better not touch the stream so long as the
parser is still using it. This means no reading, writing, seeking,
or resetting of the stream. Anything that will/could change the
current stream's offset is PROHIBITED.
It is also recommended that you not use StreamExt::tell
because it will not necessarily give you the current self
offset
since self
handles its own internal read-ahead buffer. Instead,
it is recommended that you use ParserExt::tell
if you have a
reason to need the current offset of the self
.
stream
raw message or part stream
fn set_format(&self, format: Format)
fn set_persist_stream(&self, persist: bool)
Sets whether or not the self
's underlying stream is persistent.
If persist
is true
, the self
will attempt to construct
messages/parts whose content will remain on disk rather than being
loaded into memory so as to reduce memory usage. This is the default.
If persist
is false
, the self
will always load message content
into memory.
Note: This attribute only serves as a hint to the self
. If the
underlying stream does not support seeking, then this attribute
will be ignored.
By default, this feature is enabled if the underlying stream is seekable.
persist
persist attribute
fn set_respect_content_length(&self, respect_content_length: bool)
Sets whether or not self
should respect Content-Length headers
when deciding where to look for the start of the next message. Only
used when the parser is also set to scan for From-lines.
Most notably useful when parsing broken Solaris mbox files (See http://www.jwz.org/doc/content-length.html for details).
By default, this feature is disabled.
respect_content_length
true
if the parser should use Content-Length headers or false
otherwise.
fn tell(&self) -> i64
Gets the current stream offset from the parser's internal stream.
Returns
the current stream offset from the parser's internal stream or %-1 on error.
Implementors
impl<O: IsA<Parser>> ParserExt for O