main return more specific type
This commit is contained in:
parent
8517ac3ac7
commit
a6787d0688
4 changed files with 20 additions and 8 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -81,6 +81,12 @@ dependencies = [
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anyhow"
|
||||||
|
version = "1.0.95"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atom_syndication"
|
name = "atom_syndication"
|
||||||
version = "0.12.6"
|
version = "0.12.6"
|
||||||
|
@ -1025,8 +1031,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packard"
|
name = "packard"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
@ -16,6 +16,7 @@ toml = "0.8.19"
|
||||||
xdg = "2.5.2"
|
xdg = "2.5.2"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
indicatif = "0.17.9"
|
indicatif = "0.17.9"
|
||||||
|
anyhow = "1.0.95"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 0
|
opt-level = 0
|
||||||
|
|
13
src/data.rs
13
src/data.rs
|
@ -1,9 +1,9 @@
|
||||||
|
use anyhow::{Context, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
use reqwest::get;
|
use reqwest::get;
|
||||||
use rss::Channel;
|
use rss::Channel;
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FeedItem {
|
pub struct FeedItem {
|
||||||
|
@ -13,9 +13,14 @@ pub struct FeedItem {
|
||||||
pub pub_date: DateTime<Utc>,
|
pub pub_date: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_rss(url: &str, pb: &ProgressBar) -> Result<Channel, Box<dyn Error>> {
|
async fn fetch_rss(url: &str, pb: &ProgressBar) -> Result<Channel> {
|
||||||
let response = get(url).await?.text().await?;
|
let response = get(url)
|
||||||
let channel = Channel::read_from(response.as_bytes())?;
|
.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.inc(1);
|
||||||
pb.set_message(format!("Processing: {}", channel.title));
|
pb.set_message(format!("Processing: {}", channel.title));
|
||||||
Ok(channel)
|
Ok(channel)
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
use indicatif::ProgressStyle;
|
use indicatif::ProgressStyle;
|
||||||
use std::error::Error;
|
use tokio::io;
|
||||||
use tokio;
|
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod data;
|
mod data;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), io::Error> {
|
||||||
let config = config::validate_config();
|
let config = config::validate_config();
|
||||||
let args = config::parse_cli();
|
let args = config::parse_cli();
|
||||||
let (count, skip_amount, list) = config::collate_values(args, &config);
|
let (count, skip_amount, list) = config::collate_values(args, &config);
|
||||||
|
|
Loading…
Add table
Reference in a new issue