1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
use crate::core::*; use crate::types::*; named!(pub section_part<Vec<u32>>, do_parse!( part: number >> rest: many0!(do_parse!( tag!(".") >> part: number >> (part) )) >> ({ let mut res = vec![part]; res.extend(rest); res }) )); named!(pub section_msgtext<MessageSection>, alt!( do_parse!( tag_no_case!("HEADER.FIELDS") >> opt!(tag_no_case!(".NOT")) >> tag!(" ") >> parenthesized_list!(astring) >> (MessageSection::Header)) | do_parse!(tag_no_case!("HEADER") >> (MessageSection::Header)) | do_parse!(tag_no_case!("TEXT") >> (MessageSection::Text)) )); named!(pub section_text<MessageSection>, alt!( section_msgtext | do_parse!(tag_no_case!("MIME") >> (MessageSection::Mime)) )); named!(pub section_spec<SectionPath>, alt!( map!(section_msgtext, |val| SectionPath::Full(val)) | do_parse!( part: section_part >> text: opt!(do_parse!( tag!(".") >> text: section_text >> (text) )) >> (SectionPath::Part(part, text)) ) )); named!(pub section<Option<SectionPath>>, do_parse!( tag!("[") >> spec: opt!(section_spec) >> tag!("]") >> (spec) )); named!(pub msg_att_body_section<AttributeValue>, do_parse!( tag_no_case!("BODY") >> section: section >> index: opt!(do_parse!( tag!("<") >> num: number >> tag!(">") >> (num) )) >> tag!(" ") >> data: nstring >> (AttributeValue::BodySection { section, index, data }) ));