Crates.io | letterman_email_body_parser |
lib.rs | letterman_email_body_parser |
version | 1.0.5 |
source | src |
created_at | 2021-12-08 15:25:22.074808 |
updated_at | 2022-03-04 22:39:52.911311 |
description | this is a tokio based fast and optimized email body parser and dkim validator. |
homepage | https://github.com/gzbakku/letterman_email_body_parser |
repository | https://github.com/gzbakku/letterman_email_body_parser |
max_upload_size | |
id | 494573 |
size | 137,345 |
this is a tokio based email body parser and dkim validator, the input should not include the data end flag "\r\n.\r\n",dkim keys are cached in a tokio RwLock for fatser reads, if no dkim is provided validation returns successfull.
use letterman_email_body_parser::{init,Config,io};
#[tokio::main]
async fn main() {
//io is for testing this is exposed as a module so keep that in mind
let value:String;
match io::read_string("./gl_alt_atch.txt"){
Ok(v)=>{value = v;},
Err(_)=>{
println!("failed-read_file");
return;
}
}
let hold:Vec<&str> = value.split("\r\n").collect();
let conf:Config;
match Config::new(){
Ok(v)=>{conf = v;},
Err(_)=>{
println!("failed-conf");
return;
}
}
match init(hold,&conf){
Ok(mut email)=>{
println!("email body parsed");
match email.validate(&conf).await{
Ok(_)=>{
println!("email validated");
},
Err(_e)=>{
println!("email validation failed : {:?}",_e);
}
}
},
Err(_e)=>{
println!("email body failed : {:?}",_e);
}
}
}