podal/src/feed/mod.rs

28 lines
734 B
Rust
Raw Normal View History

use crate::prelude::*;
use crate::network::{NetUrl, NetworkEnv};
use atom_syndication::Feed;
2023-07-25 10:46:47 +01:00
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())
}
}