crabmail

Static HTML email archive viewer in Rust
git clone git://git.alexwennerberg.com/crabmail
Log | Files | Refs | README | LICENSE

commit 402c572ddb0754e4eb855a4a3df556b15d827834
parent d9d183e62b2bd4c16e1eee0fe1b9a04cdcc819ae
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu, 16 Dec 2021 20:04:59 -0800

Bring mbox parsing in house

Diffstat:
MCargo.lock | 20--------------------
MCargo.toml | 1-
Msrc/main.rs | 12+++++++-----
3 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -78,7 +78,6 @@ dependencies = [ "horrorshow", "linkify", "mailparse", - "mbox-reader", "once_cell", "pico-args", "quick-xml", @@ -279,31 +278,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] -name = "mbox-reader" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6231e973c0a8caceed71fac7355555012ba73fe230365989b298b36022e9e2ab" -dependencies = [ - "memmap", -] - -[[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - -[[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -16,7 +16,6 @@ anyhow = "1.0" horrorshow = "0.8.4" linkify = "0.8.0" mailparse = "0.13" -mbox-reader = "0.2.0" #unamaintained, should remove dep once_cell = "1.9" pico-args = "0.4.1" quick-xml = "0.22" diff --git a/src/main.rs b/src/main.rs @@ -6,12 +6,12 @@ use horrorshow::Template; use std::io; use std::io::BufWriter; use std::path::Path; +use std::str; #[macro_use] extern crate horrorshow; use mailparse::*; -use mbox_reader::MboxFile; use sha3::{ digest::{ExtendableOutput, Update, XofReader}, Shake128, @@ -23,6 +23,7 @@ use urlencoding; use config::{Config, INSTANCE}; mod config; +mod mbox; mod utils; // TODO be more clear about the expected input types @@ -325,14 +326,15 @@ fn main() -> Result<()> { let config = Config::from_file(&config_file).unwrap(); // TODO better err handling INSTANCE.set(config).unwrap(); - let mbox = MboxFile::from_file(&in_mbox)?; + let mbox = mbox::from_file(&in_mbox)?; let mut thread_index: HashMap<String, Vec<String>> = HashMap::new(); let mut email_index: HashMap<String, Email> = HashMap::new(); - for entry in mbox.iter() { - let buffer = entry.message().unwrap(); - let email = match local_parse_email(buffer) { + for entry in mbox { + let buffer = entry.unwrap(); + // println!("{}", str::from_utf8(&buffer)?); + let email = match local_parse_email(&buffer) { Ok(e) => e, Err(e) => { println!("{:?}", e);