aerogramme/src/mail/mod.rs

30 lines
780 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
2023-05-15 16:23:23 +00:00
// 2023-05-15 don't want to refactor this struct now.
#[allow(clippy::upper_case_acronyms)]
pub struct IMF<'a> {
raw: &'a [u8],
parsed: eml_codec::part::composite::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 ----");
let parsed = eml_codec::parse_message(body).or(Err(()))?.1;
2022-06-29 17:24:21 +00:00
Ok(Self { raw: body, parsed })
}
}