Index: src/lib.rs ================================================================== --- src/lib.rs +++ src/lib.rs @@ -1,10 +1,20 @@ -mod mail; +pub mod mail; mod telegram; pub mod utils; +// As we are not actually exporting this lib there would be no local Error's for +// now, everything will be just .stack()?'ed and propagated like in real bin +// The lib here is just to separate all tests from main code into tests/ + use crate::mail::MailServer; + +use std::{ + io::Cursor, + os::unix::fs::PermissionsExt, + path::Path, +}; use just_getopt::{ OptFlags, OptSpecs, OptValue, @@ -16,16 +26,10 @@ Result, StackableErr, bail, }; -use std::{ - io::Cursor, - os::unix::fs::PermissionsExt, - path::Path, -}; - /// Actual main function running async with Error propagation support pub async fn async_main () -> Result<()> { let specs = OptSpecs::new() .option("help", "h", OptValue::None) .option("help", "help", OptValue::None) @@ -64,11 +68,13 @@ .set_default("api_gateway", "https://api.telegram.org").stack()? .set_default("fields", vec!["date", "from", "subject"]).stack()? .set_default("hostname", "smtp.2.tg").stack()? .set_default("listen_on", "0.0.0.0:1025").stack()? .set_default("unknown", "relay").stack()? - .set_default("domains", vec!["localhost", hostname::get().stack()?.to_str().expect("Failed to get current hostname")]).stack()? + .set_default("domains", vec!["localhost", + hostname::get().expect("Failed to get current hostname") + .to_str().expect("Can't convert hostname to string, bad UTF-8?")]).stack()? .add_source(config::File::from(config_file)) .build() .with_context(|| format!("[{config_file:?}] there was an error reading config\n\ \tplease consult \"smtp2tg.toml.example\" for details"))?;