atom_syndication

Struct Content

Source
pub struct Content {
    pub base: Option<String>,
    pub lang: Option<String>,
    pub value: Option<String>,
    pub src: Option<String>,
    pub content_type: Option<String>,
}
Expand description

Represents the content of an Atom entry

§Attention

Atom format specification RFC4287 states that src and value (content) fields are mutually exclusive:

atom:content MAY have a “src” attribute, whose value MUST be an IRI reference. If the “src” attribute is present, atom:content MUST be empty.

Setting of both fields when authoring an Atom feed is still technically possible, but it will lead to a non-compliant result.

Fields§

§base: Option<String>

Base URL for resolving any relative references found in the element.

§lang: Option<String>

Indicates the natural language for the element.

§value: Option<String>

The text value of the content.

§src: Option<String>

The URI of where the content can be found.

§content_type: Option<String>

Either “text”, “html”, “xhtml”, or the MIME type of the content.

Implementations§

Source§

impl Content

Source

pub fn base(&self) -> Option<&str>

Return base URL of the content.

Source

pub fn set_base<V>(&mut self, base: V)
where V: Into<Option<String>>,

Set base URL of the content.

Source

pub fn lang(&self) -> Option<&str>

Return natural language of the content.

Source

pub fn set_lang<V>(&mut self, lang: V)
where V: Into<Option<String>>,

Set the base URL of the content.

Source

pub fn value(&self) -> Option<&str>

Return the text value of the content.

If the content_type is neither "text", "html", or "xhtml" then the value should be a base64 encoded document of the indicated MIME type.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_value("Example content".to_string());
assert_eq!(content.value(), Some("Example content"));
Source

pub fn set_value<V>(&mut self, value: V)
where V: Into<Option<String>>,

Set the text value of the content.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_value("Example content".to_string());
Source

pub fn src(&self) -> Option<&str>

Return the URI where the content can be found.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_src("http://example.com/content.html".to_string());
assert_eq!(content.src(), Some("http://example.com/content.html"));
Source

pub fn set_src<V>(&mut self, src: V)
where V: Into<Option<String>>,

Set the URI where the content can be found.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_src("http://example.com/content.html".to_string());
Source

pub fn content_type(&self) -> Option<&str>

Return the type of the content.

The type is either "text", "html", "xhtml", or the MIME type of the content.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_content_type("image/png".to_string());
assert_eq!(content.content_type(), Some("image/png"));
Source

pub fn set_content_type<V>(&mut self, content_type: V)
where V: Into<Option<String>>,

Set the type of the content.

§Examples
use atom_syndication::Content;

let mut content = Content::default();
content.set_content_type("image/png".to_string());
assert_eq!(content.content_type(), Some("image/png"));

Trait Implementations§

Source§

impl Clone for Content

Source§

fn clone(&self) -> Content

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 Debug for Content

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Content

Source§

fn default() -> Content

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

impl PartialEq for Content

Source§

fn eq(&self, other: &Content) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Content

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.