commit 3fe96bd12a76b76458f85d936050cf782bce0c16 from: witcher date: Mon Aug 15 14:02:53 2022 UTC Fix formatting commit - 69bfb4f36f0b25583d31dfdd9dc2c7932eabb4d2 commit + 3fe96bd12a76b76458f85d936050cf782bce0c16 blob - abd6eaefdb548d8a5121acd417b285fcf4a8381e blob + 3bf783cf5503a1f71f7238cce1ad4a7b01acab6d --- src/cli.rs +++ src/cli.rs @@ -36,7 +36,10 @@ impl Cli { // ensure project config directory exists if !c_dir.exists() { - debug!("Config directory at {:?} does not exist, creating it.", c_dir); + debug!( + "Config directory at {:?} does not exist, creating it.", + c_dir + ); fs::create_dir(c_dir)?; } blob - 85c1ee63806afb4fcefa06f257000848678997ee blob + 6b8db99b6e78ee8aaff812259d9c765e2fc177d5 --- src/config.rs +++ src/config.rs @@ -1,6 +1,6 @@ +use anyhow::Context; use serde::Deserialize; use std::fs::File; -use anyhow::Context; use std::{io::Read, path::Path}; #[derive(Debug, Deserialize)] @@ -22,10 +22,7 @@ impl Config { pub fn new(config_path: impl AsRef) -> anyhow::Result { let mut string = String::new(); File::open(config_path.as_ref()) - .context(format!( - "File {:?} does not exist", - &config_path.as_ref() - ))? + .context(format!("File {:?} does not exist", &config_path.as_ref()))? .read_to_string(&mut string)?; let config: Config = toml::de::from_str(&string)?; blob - 35075ef09abae29483866db27c732082673f405a blob + 34e1430a519195e4298fa3956d7a002f5bc85c90 --- src/mail.rs +++ src/mail.rs @@ -1,10 +1,7 @@ use crate::config::Config; use lettre::{ message::Message, - transport::smtp::{ - authentication::Credentials, - SmtpTransport, - }, + transport::smtp::{authentication::Credentials, SmtpTransport}, Transport, }; blob - 23cf3199ce6465637290ec3eaef1437312d61b0c blob + 156cc104f6b1d2ca9ecf492f4f9893c292758ee2 --- src/main.rs +++ src/main.rs @@ -16,6 +16,7 @@ pub mod rss; pub mod schema; use self::diesel::prelude::*; +use crate::mail::{get_mailer, send_email}; use anyhow::Context; use config::Config; use schema::posts::dsl::*; @@ -23,7 +24,6 @@ use std::{ fs::File, io::{BufRead, BufReader}, }; -use crate::mail::{get_mailer, send_email}; fn main() -> anyhow::Result<()> { diesel_migrations::embed_migrations!("migrations/"); @@ -67,7 +67,12 @@ fn main() -> anyhow::Result<()> { Ok(()) } -fn send_posts(conn: &SqliteConnection, config: &Config, items: Vec, dry_run: bool) -> anyhow::Result<()> { +fn send_posts( + conn: &SqliteConnection, + config: &Config, + items: Vec, + dry_run: bool, +) -> anyhow::Result<()> { let mailer = get_mailer(config)?; for mut post in items { if !dry_run { @@ -79,7 +84,9 @@ fn send_posts(conn: &SqliteConnection, config: &Config send_email(config, subject, body, &mailer)?; } post.sent = true; - diesel::update(schema::posts::dsl::posts.find(post.guid)).set(sent.eq(true)).execute(conn)?; + diesel::update(schema::posts::dsl::posts.find(post.guid)) + .set(sent.eq(true)) + .execute(conn)?; } Ok(())