rss_actions/models/feed.rs
1use anyhow::{anyhow, Result};
2use url::Url;
3
4#[derive(Debug, Clone)]
5pub struct Feed {
6 /// The feed's URL.
7 pub url: Url,
8 /// The user-chosen alias for the feed. Must not be empty.
9 pub alias: String,
10}
11
12impl Feed {
13 pub fn new(url: Url, alias: &str) -> Result<Feed> {
14 if alias.is_empty() {
15 return Err(anyhow!("A feed's alias must not be empty. {}", url));
16 }
17 Ok(Feed {
18 url,
19 alias: alias.into(),
20 })
21 }
22}