add a imf::message fx
This commit is contained in:
parent
e963965e77
commit
efe037aa25
3 changed files with 21 additions and 4 deletions
15
src/lib.rs
15
src/lib.rs
|
@ -4,3 +4,18 @@ pub mod header;
|
|||
pub mod rfc5322;
|
||||
pub mod mime;
|
||||
pub mod part;
|
||||
|
||||
/*
|
||||
use crate::part;
|
||||
use crate::mime;
|
||||
use crate::rfc5322 as imf;
|
||||
use crate::header;
|
||||
|
||||
pub fn email(input: &[u8]) -> Result<part::part::Message> {
|
||||
message(mime::mime::Message::default())(input).map(|(_, v)| v)
|
||||
}
|
||||
|
||||
pub fn imf(input: &[u8]) -> Result<imf::message::Message> {
|
||||
header::header(imf::field::field)
|
||||
map(header(field), |v| FieldList(v.known()).message())(fullmail)
|
||||
}*/
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::rfc5322::identification::{MessageID, MessageIDList, msg_id, msg_list}
|
|||
use crate::rfc5322::trace::{ReceivedLog, return_path, received_log};
|
||||
use crate::rfc5322::mime::{Version, version};
|
||||
use crate::rfc5322::message::Message;
|
||||
use crate::header::{field_name};
|
||||
use crate::header::{field_name, header};
|
||||
use crate::text::misc_token::{Unstructured, PhraseList, unstructured, phrase_list};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
@ -86,6 +86,10 @@ pub fn field(input: &[u8]) -> IResult<&[u8], Field> {
|
|||
)), obs_crlf)(input)
|
||||
}
|
||||
|
||||
pub fn message(input: &[u8]) -> IResult<&[u8], Message> {
|
||||
map(header(field), |v| FieldList(v.known()).message())(input)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -93,7 +97,6 @@ mod tests {
|
|||
use crate::rfc5322::mailbox::*;
|
||||
use crate::rfc5322::address::*;
|
||||
use crate::text::misc_token::*;
|
||||
use crate::header::header;
|
||||
|
||||
#[test]
|
||||
fn test_header() {
|
||||
|
@ -106,7 +109,7 @@ This is the plain text body of the message. Note the blank line
|
|||
between the header information and the body of the message.";
|
||||
|
||||
assert_eq!(
|
||||
map(header(field), |v| FieldList(v.known()).message())(fullmail),
|
||||
message(fullmail),
|
||||
Ok((
|
||||
&b"This is the plain text body of the message. Note the blank line\nbetween the header information and the body of the message."[..],
|
||||
Message {
|
||||
|
|
|
@ -71,4 +71,3 @@ impl<'a> FromIterator<Field<'a>> for Message<'a> {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue