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
|
|
|
|
2022-06-30 15:40:59 +00:00
|
|
|
pub mod incoming;
|
2022-06-29 11:16:58 +00:00
|
|
|
pub mod mailbox;
|
2022-06-29 13:39:54 +00:00
|
|
|
pub mod uidindex;
|
2022-06-29 13:52:09 +00:00
|
|
|
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)]
|
2022-06-29 13:39:54 +00:00
|
|
|
pub struct IMF<'a> {
|
|
|
|
raw: &'a [u8],
|
2023-07-25 08:59:48 +00:00
|
|
|
parsed: eml_codec::part::composite::Message<'a>,
|
2022-06-29 13:39:54 +00:00
|
|
|
}
|
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 ----");
|
2023-07-25 08:59:48 +00:00
|
|
|
let parsed = eml_codec::parse_message(body).or(Err(()))?.1;
|
2022-06-29 17:24:21 +00:00
|
|
|
Ok(Self { raw: body, parsed })
|
|
|
|
}
|
|
|
|
}
|