Struct sitemap_xml_writer::Url

source ·
pub struct Url<'a> { /* private fields */ }
Expand description

A builder for url entry.

Examples

Url::loc("http://www.example.com/")?
    .lastmod("2005-01-01")?
    .changefreq("monthly")?
    .priority("0.8")?;
Url::loc(::url::Url::parse("http://www.example.com/")?)?
    .lastmod(::chrono::NaiveDate::parse_from_str("2005-01-01", "%Y-%m-%d")?)?
    .changefreq(Changefreq::Monthly)?
    .priority(0.8)?;
Url::loc(::url::Url::parse("http://www.example.com/")?)?
    .lastmod(::time::macros::date!(2005-01-01))?
    .changefreq(Changefreq::Monthly)?
    .priority(0.8)?;

Implementations§

source§

impl<'a> Url<'a>

source

pub fn loc<S>(loc: S) -> Result<Self, Error>where S: TryInto<Loc<'a>>,

Builds a url entry with the specified URL as the content of the loc child entry.

Examples
Url::loc("http://www.example.com/")?;
Url::loc(::url::Url::parse("http://www.example.com/")?)?;
source

pub fn changefreq<S>(self, s: S) -> Result<Self, Error>where S: TryInto<Changefreq>,

Changes the changefreq child entry to the specified value.

Examples
Url::loc("http://www.example.com/")?
    .changefreq("monthly")?;

Url::loc("http://www.example.com/")?
    .changefreq(Changefreq::Monthly)?;
source

pub fn lastmod<S>(self, s: S) -> Result<Self, Error>where S: TryInto<Lastmod<'a>>,

Changes the lastmod child entry to the specified date or datetime.

Examples
Url::loc("http://www.example.com/")?
    .lastmod("2004-10-01T18:23:17+00:00")?;
Url::loc("http://www.example.com/")?
    .lastmod(::time::macros::datetime!(2004-10-01 18:23:17+00:00))?;
source

pub fn priority<S>(self, s: S) -> Result<Self, Error>where S: TryInto<Priority<'a>>,

Changes the priority child entry to the specified value.

Examples
Url::loc("http://www.example.com/")?
    .priority("0.8")?;

Url::loc("http://www.example.com/")?
    .priority(0.8)?;

Trait Implementations§

source§

impl<'a> TryFrom<&'a str> for Url<'a>

§

type Error = Error

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

fn try_from(value: &'a str) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Url<'a>

§

impl<'a> Send for Url<'a>

§

impl<'a> Sync for Url<'a>

§

impl<'a> Unpin for Url<'a>

§

impl<'a> UnwindSafe for Url<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.