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