niax / rust-email

Implementation of MIME Messages for Rust
MIT License
63 stars 34 forks source link

Reading headers without the rest of the message #30

Open jugglerchris opened 8 years ago

jugglerchris commented 8 years ago

I'm experimenting with rust-email for an e-mail client project.

I need to read the headers from many messages (ie a mailbox), without having to read in and parse the entire (possibly huge) e-mail bodies, to display a message index.

The best option I can see so far is to manually read chunks from each message and scan myself until I can see a double line break, then feed that data into an Rfc5322 and call consume_header() repeatedly. Which is fine, but it's a shame to have to duplicate a small part of the parsing. It'd be nice for me if the the parser could work from a std::io::Read or std::io::BufRead, say, and so take either a file or string. (Acknowledging that UTF-8 handling needs doing somewhere!)

I'd be interested in suggestions of better ways to do it, or changes/additions to this crate which might happen in future.