Struct ItemBuilder

Source
pub struct ItemBuilder { /* private fields */ }
Expand description

This ItemBuilder struct creates the Item.

Implementations§

Source§

impl ItemBuilder

Source

pub fn new() -> ItemBuilder

Construct a new ItemBuilder and return default values.

§Examples
use feed::ItemBuilder;

let item_builder = ItemBuilder::new();
Source

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()));

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()));
Source

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()));
Source

pub fn author(&mut self, author: Option<String>) -> &mut ItemBuilder

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()));
Source

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);
Source

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()));
Source

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));
Source

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));
Source

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()));
Source

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));
Source

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));
Source

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();
Source

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

Source§

fn clone(&self) -> ItemBuilder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ItemBuilder

Source§

fn default() -> ItemBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.