commit 274c1d64ae73752876251006a4fa590084696f22 from: Thomas Böhler date: Thu Oct 23 18:49:40 2025 UTC refactor: make function order more predictable Signed-off-by: Thomas Böhler commit - 42b9afc7376731c380939c6411a8d5f4ae11938c commit + 274c1d64ae73752876251006a4fa590084696f22 blob - 6b2e87de385abb99e2a152ce25a89a637fad050c blob + 765296b9ac837c9a6a30c9549aa257a7587bff5e --- src/main.rs +++ src/main.rs @@ -61,17 +61,6 @@ pub enum Error { Config { source: crate::config::Error }, } -#[tokio::main] -async fn main() { - if let Err(e) = app_main().await { - eprintln!("The following errors were encountered:"); - for err in e { - eprintln!("{err}"); - } - std::process::exit(1); - } -} - async fn fetcher(urls: Vec, tx: Sender) -> Result<(), Error> { let mut set = JoinSet::new(); for u in urls { @@ -176,6 +165,27 @@ async fn accumulator( Ok(()) } +async fn send_post<'a>( + conn: &mut PoolConnection, + mailer: AsyncSmtpTransport, + from: &'a str, + to: &'a str, + post: models::Post, + dry_run: bool, +) -> Result<(), Error> { + if !dry_run { + log::debug!("Sending post with guid '{}'", post.guid); + Mail::new(post.title, post.content, post.url) + .send_email(from, to, &mailer) + .await + .context(MailSnafu)?; + } + + set_sent(&post.guid, conn).await?; + + Ok(()) +} + async fn sender( config: &AppConfig, mut conn: PoolConnection, @@ -272,23 +282,13 @@ async fn app_main() -> Result<(), Vec> { } } -async fn send_post<'a>( - conn: &mut PoolConnection, - mailer: AsyncSmtpTransport, - from: &'a str, - to: &'a str, - post: models::Post, - dry_run: bool, -) -> Result<(), Error> { - if !dry_run { - log::debug!("Sending post with guid '{}'", post.guid); - Mail::new(post.title, post.content, post.url) - .send_email(from, to, &mailer) - .await - .context(MailSnafu)?; +#[tokio::main] +async fn main() { + if let Err(e) = app_main().await { + eprintln!("The following errors were encountered:"); + for err in e { + eprintln!("{err}"); + } + std::process::exit(1); } - - set_sent(&post.guid, conn).await?; - - Ok(()) }