pub struct EmlParser { /* private fields */ }
Implementations§
Source§impl EmlParser
impl EmlParser
Sourcepub fn from_file(filename: impl AsRef<Path>) -> Result<Self, EmlError>
pub fn from_file(filename: impl AsRef<Path>) -> Result<Self, EmlError>
Read an .eml file from disk, parsing its contents.
Note that the current implementation loads the entire file to memory since std::fs::File
doesn’t provide an iterator over char
that could give a Peekable
.
Examples found in repository?
examples/parse.rs (line 5)
4fn main() -> Result<(), EmlError> {
5 let mut eml = EmlParser::from_file("test_emails/0.eml")?;
6 if let Ok(parsed) = eml.parse() {
7 println!("{:?}", parsed.to);
8 } else {
9 println!("Failed to parse");
10 }
11 println!();
12
13 let mut eml = EmlParser::from_file("test_emails/1.eml")?;
14 if let Ok(parsed) = eml.parse() {
15 println!("{:?}", parsed.to);
16 } else {
17 println!("Failed to parse");
18 }
19
20 Ok(())
21}
pub fn from_string(content: String) -> Self
pub fn ignore_body(self) -> Self
pub fn with_body(self) -> Self
pub fn with_body_preview(self, bytes: usize) -> Self
Sourcepub fn parse(&mut self) -> Result<Eml, EmlError>
pub fn parse(&mut self) -> Result<Eml, EmlError>
Examples found in repository?
examples/parse.rs (line 6)
4fn main() -> Result<(), EmlError> {
5 let mut eml = EmlParser::from_file("test_emails/0.eml")?;
6 if let Ok(parsed) = eml.parse() {
7 println!("{:?}", parsed.to);
8 } else {
9 println!("Failed to parse");
10 }
11 println!();
12
13 let mut eml = EmlParser::from_file("test_emails/1.eml")?;
14 if let Ok(parsed) = eml.parse() {
15 println!("{:?}", parsed.to);
16 } else {
17 println!("Failed to parse");
18 }
19
20 Ok(())
21}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EmlParser
impl RefUnwindSafe for EmlParser
impl Send for EmlParser
impl Sync for EmlParser
impl Unpin for EmlParser
impl UnwindSafe for EmlParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more