pub struct ItemBuilder { /* private fields */ }
Expand description
This ItemBuilder
struct creates the Item
.
Implementations§
Source§impl ItemBuilder
impl ItemBuilder
Sourcepub fn new() -> ItemBuilder
pub fn new() -> ItemBuilder
Construct a new ItemBuilder
and return default values.
§Examples
use feed::ItemBuilder;
let item_builder = ItemBuilder::new();
Sourcepub fn title(&mut self, title: Option<String>) -> &mut ItemBuilder
pub fn title(&mut self, title: Option<String>) -> &mut ItemBuilder
Set the optional title that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.title(Some("Making Music with Linux | LAS
408".to_owned()));
Sourcepub fn link(&mut self, link: Option<String>) -> &mut ItemBuilder
pub fn link(&mut self, link: Option<String>) -> &mut ItemBuilder
Set the optional link that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.link(Some("http://www.jupiterbroadcasting.com".
to_owned()));
Sourcepub fn description(&mut self, description: Option<String>) -> &mut ItemBuilder
pub fn description(&mut self, description: Option<String>) -> &mut ItemBuilder
Set the optional description that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.description(Some("This is a test description".to_owned()));
Set the optional author that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.author(Some("Chris Fisher".to_owned()));
Sourcepub fn categories(&mut self, categories: Vec<Category>) -> &mut ItemBuilder
pub fn categories(&mut self, categories: Vec<Category>) -> &mut ItemBuilder
Set the optional categories that exists under Item
.
§Examples
use feed::{CategoryBuilder, ItemBuilder};
let category = CategoryBuilder::new()
.finalize()
.unwrap();;
let categories = vec![category];
let mut item_builder = ItemBuilder::new();
item_builder.categories(categories);
Sourcepub fn comments(&mut self, comments: Option<String>) -> &mut ItemBuilder
pub fn comments(&mut self, comments: Option<String>) -> &mut ItemBuilder
Set the optional comments that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.comments(Some("Test Comment".to_owned()));
Sourcepub fn enclosure(&mut self, enclosure: Option<Enclosure>) -> &mut ItemBuilder
pub fn enclosure(&mut self, enclosure: Option<Enclosure>) -> &mut ItemBuilder
Set the optional enclosure that exists under Item
.
§Examples
use feed::{EnclosureBuilder, ItemBuilder};
let url = "http://www.podtrac.com/pts/redirect.ogg/".to_owned()
+ "traffic.libsyn.com/jnite/linuxactionshowep408.ogg";
let enclosure = EnclosureBuilder::new()
.url(url.as_str())
.mime_type("audio/ogg")
.finalize()
.unwrap();
let mut item_builder = ItemBuilder::new();
item_builder.enclosure(Some(enclosure));
Sourcepub fn guid(&mut self, guid: Option<Guid>) -> &mut ItemBuilder
pub fn guid(&mut self, guid: Option<Guid>) -> &mut ItemBuilder
Set the optional guid that exists under Item
.
§Examples
use feed::{GuidBuilder, ItemBuilder};
let guid = GuidBuilder::new()
.finalize()
.unwrap();
let mut item_builder = ItemBuilder::new();
item_builder.guid(Some(guid));
Sourcepub fn pub_date(&mut self, pub_date: Option<String>) -> &mut ItemBuilder
pub fn pub_date(&mut self, pub_date: Option<String>) -> &mut ItemBuilder
Set the optional pub date that exists under Item
.
§Examples
use feed::ItemBuilder;
let mut item_builder = ItemBuilder::new();
item_builder.pub_date(Some("Sun, 13 Mar 2016
20:02:02-0700".to_owned()));
Sourcepub fn source(&mut self, source: Option<Source>) -> &mut ItemBuilder
pub fn source(&mut self, source: Option<Source>) -> &mut ItemBuilder
Set the optional source that exists under Item
.
§Examples
use feed::{ItemBuilder, SourceBuilder};
let url = "http://www.tomalak.org/links2.xml";
let source = SourceBuilder::new()
.url(url)
.finalize()
.unwrap();
let mut item_builder = ItemBuilder::new();
item_builder.source(Some(source));
Sourcepub fn itunes_ext(
&mut self,
itunes_ext: Option<ITunesItemExtension>,
) -> &mut ItemBuilder
pub fn itunes_ext( &mut self, itunes_ext: Option<ITunesItemExtension>, ) -> &mut ItemBuilder
Set the optional itunes_ext that exists under Item
.
§Examples
use feed::ItemBuilder;
use feed::extension::itunes::ITunesItemExtensionBuilder;
let url = "http://www.tomalak.org/links2.xml";
let itunes_item = ITunesItemExtensionBuilder::new()
.author(Some("author".to_owned()))
.block(Some("block".to_owned()))
.image(Some("image".to_owned()))
.duration(Some("duration".to_owned()))
.explicit(Some("explicit".to_owned()))
.closed_captioned(Some("closed_captioned".to_owned()))
.order(Some("order".to_owned()))
.subtitle(Some("subtitle".to_owned()))
.summary(Some("summary".to_owned()))
.keywords(Some("keywords".to_owned()))
.finalize()
.unwrap();
let mut item_builder = ItemBuilder::new();
item_builder.itunes_ext(Some(itunes_item));
Sourcepub fn validate(&mut self) -> Result<&mut ItemBuilder, String>
pub fn validate(&mut self) -> Result<&mut ItemBuilder, String>
Validate the contents of Item
.
§Examples
use feed::ItemBuilder;
let item = ItemBuilder::new()
.title(Some("Making Music with Linux | LAS 408".to_owned()))
.link(Some("http://www.jupiterbroadcasting.com".to_owned()))
.description(None)
.author(None)
.categories(Vec::new())
.comments(None)
.enclosure(None)
.guid(None)
.pub_date(None)
.source(None)
.validate().unwrap()
.finalize().unwrap();
Sourcepub fn finalize(&self) -> Result<Item, String>
pub fn finalize(&self) -> Result<Item, String>
Construct the Item
from the ItemBuilder
.
§Examples
use feed::ItemBuilder;
let item = ItemBuilder::new()
.title(Some("Making Music with Linux | LAS 408".to_owned()))
.link(Some("http://www.jupiterbroadcasting.com".to_owned()))
.description(None)
.author(None)
.categories(Vec::new())
.comments(None)
.enclosure(None)
.guid(None)
.pub_date(None)
.source(None)
.finalize()
.unwrap();
Trait Implementations§
Source§impl Clone for ItemBuilder
impl Clone for ItemBuilder
Source§fn clone(&self) -> ItemBuilder
fn clone(&self) -> ItemBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for ItemBuilder
impl Default for ItemBuilder
Source§fn default() -> ItemBuilder
fn default() -> ItemBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ItemBuilder
impl RefUnwindSafe for ItemBuilder
impl Send for ItemBuilder
impl Sync for ItemBuilder
impl Unpin for ItemBuilder
impl UnwindSafe for ItemBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more