aerogramme/src/mail/mod.rs

28 lines
672 B
Rust
Raw Normal View History

2022-06-29 17:24:21 +00:00
use std::convert::TryFrom;
2022-07-15 14:15:48 +00:00
use std::io::Write;
2022-06-29 17:24:21 +00:00
pub mod incoming;
2022-06-29 11:16:58 +00:00
pub mod mailbox;
pub mod uidindex;
pub mod unique_ident;
2022-06-29 11:41:05 +00:00
pub mod user;
2022-06-27 14:56:20 +00:00
2022-06-28 08:49:28 +00:00
// Internet Message Format
// aka RFC 822 - RFC 2822 - RFC 5322
pub struct IMF<'a> {
raw: &'a [u8],
parsed: mail_parser::Message<'a>,
}
2022-06-29 17:24:21 +00:00
impl<'a> TryFrom<&'a [u8]> for IMF<'a> {
type Error = ();
fn try_from(body: &'a [u8]) -> Result<IMF<'a>, ()> {
2022-07-15 14:15:48 +00:00
eprintln!("---- BEGIN PARSED MESSAGE ----");
let _ = std::io::stderr().write_all(body);
eprintln!("---- END PARSED MESSAGE ----");
2022-06-29 17:24:21 +00:00
let parsed = mail_parser::Message::parse(body).ok_or(())?;
Ok(Self { raw: body, parsed })
}
}