Paul Campbell
29f62a279b
Closes kemitix/podal#4 Reviewed-on: #21 Co-authored-by: Paul Campbell <pcampbell@kemitix.net> Co-committed-by: Paul Campbell <pcampbell@kemitix.net>
27 lines
734 B
Rust
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())
|
|
}
|
|
}
|