use SourceBuilder;
use rss::Source;
use utils::string_utils;
impl SourceBuilder
{
pub fn new() -> SourceBuilder
{
SourceBuilder::default()
}
pub fn url(&mut self, url: &str) -> &mut SourceBuilder
{
self.url = url.to_owned();
self
}
pub fn title(&mut self, title: Option<String>) -> &mut SourceBuilder
{
self.title = title;
self
}
pub fn validate(&mut self) -> Result<&mut SourceBuilder, String>
{
string_utils::str_to_url(self.url.as_str())?;
Ok(self)
}
pub fn finalize(&self) -> Result<Source, String>
{
Ok(Source {
url: self.url.clone(),
title: self.title.clone(),
})
}
}