2023-06-19 15:25:16 +00:00
|
|
|
use imf_codec::fragments::header;
|
2023-06-18 19:17:27 +00:00
|
|
|
use std::io;
|
|
|
|
use std::io::Read;
|
2023-06-08 12:58:20 +00:00
|
|
|
|
2023-06-18 20:05:11 +00:00
|
|
|
|
2023-06-08 12:58:20 +00:00
|
|
|
fn main() {
|
2023-06-18 20:05:11 +00:00
|
|
|
// Read full mail in memory
|
|
|
|
let mut rawmail = Vec::new();
|
|
|
|
io::stdin().lock().read_to_end(&mut rawmail).unwrap();
|
|
|
|
|
2023-06-19 09:22:51 +00:00
|
|
|
// Parse it
|
|
|
|
let (email, encoding, malformed) = header::from_bytes(&rawmail);
|
2023-06-18 20:05:11 +00:00
|
|
|
println!("Encoding: {:?}, Malformed: {:?}", encoding, malformed);
|
2023-06-13 11:42:50 +00:00
|
|
|
|
2023-06-19 09:22:51 +00:00
|
|
|
let (input, hdrs) = header::section(&email).unwrap();
|
2023-06-18 20:17:55 +00:00
|
|
|
|
2023-06-19 09:22:51 +00:00
|
|
|
// Checks/debug
|
2023-06-18 20:17:55 +00:00
|
|
|
println!("{:?}", hdrs);
|
2023-06-18 19:17:27 +00:00
|
|
|
assert!(hdrs.date.is_some());
|
|
|
|
assert!(hdrs.from.len() > 0);
|
2023-06-18 20:17:55 +00:00
|
|
|
assert!(hdrs.bad_fields.len() == 0);
|
2023-06-08 12:58:20 +00:00
|
|
|
}
|