podal/src/feed/mod.rs
Paul Campbell 29f62a279b
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
f4-dir-per-channel (#21)
Closes kemitix/podal#4

Reviewed-on: #21
Co-authored-by: Paul Campbell <pcampbell@kemitix.net>
Co-committed-by: Paul Campbell <pcampbell@kemitix.net>
2024-01-23 08:06:28 +00:00

27 lines
734 B
Rust

use crate::prelude::*;
use crate::network::{NetUrl, NetworkEnv};
use atom_syndication::Feed;
mod find;
pub use find::find;
pub fn get(url: &NetUrl, e: &NetworkEnv) -> Result<Feed> {
let content = (e.fetch_as_bytes)(url).context(format!("Fetching feed: {}", url))?;
let channel = Feed::read_from(&content[..]).context("Could not parse RSS feed")?;
Ok(channel)
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ChannelName(pub String);
impl ChannelName {
pub fn from(channel_name: &str) -> Self {
Self(channel_name.to_string())
}
}
impl std::fmt::Display for ChannelName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.as_str())
}
}