aboutsummaryrefslogblamecommitdiff
path: root/aero-collections/src/mail/mod.rs
blob: 584a9ebe3e72a18745c60ca980da697186dd6cd3 (plain) (tree)
1
2
3
4
5
6
7
8
9
                 
                
                  
              
                 
                 
 

                                    

                                                     

                    
                                                    
 




                                                        
                                                                   


                                      
pub mod incoming;
pub mod mailbox;
pub mod namespace;
pub mod query;
pub mod snapshot;
pub mod uidindex;

// Internet Message Format
// aka RFC 822 - RFC 2822 - RFC 5322
// 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>,
}

impl<'a> TryFrom<&'a [u8]> for IMF<'a> {
    type Error = ();

    fn try_from(body: &'a [u8]) -> Result<IMF<'a>, ()> {
        let parsed = eml_codec::parse_message(body).or(Err(()))?.1;
        Ok(Self { raw: body, parsed })
    }
}