main return more specific type

This commit is contained in:
Troy 2025-01-16 21:21:51 +00:00
parent 8517ac3ac7
commit a6787d0688
Signed by: troy
GPG key ID: DFC06C02ED3B4711
4 changed files with 20 additions and 8 deletions

View file

@ -1,9 +1,9 @@
use anyhow::{Context, Result};
use chrono::{DateTime, Utc};
use futures::future::join_all;
use indicatif::ProgressBar;
use reqwest::get;
use rss::Channel;
use std::error::Error;
#[derive(Debug)]
pub struct FeedItem {
@ -13,9 +13,14 @@ pub struct FeedItem {
pub pub_date: DateTime<Utc>,
}
async fn fetch_rss(url: &str, pb: &ProgressBar) -> Result<Channel, Box<dyn Error>> {
let response = get(url).await?.text().await?;
let channel = Channel::read_from(response.as_bytes())?;
async fn fetch_rss(url: &str, pb: &ProgressBar) -> Result<Channel> {
let response = get(url)
.await
.context("Failed to send request")?
.text()
.await
.context("Failed to read response text")?;
let channel = Channel::read_from(response.as_bytes()).context("Failed to parse RSS feed")?;
pb.inc(1);
pb.set_message(format!("Processing: {}", channel.title));
Ok(channel)

View file

@ -1,13 +1,12 @@
use indicatif::ProgressStyle;
use std::error::Error;
use tokio;
use tokio::io;
mod config;
mod data;
mod utils;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
async fn main() -> Result<(), io::Error> {
let config = config::validate_config();
let args = config::parse_cli();
let (count, skip_amount, list) = config::collate_values(args, &config);