Struct rss::Image

source ·
pub struct Image {
    pub url: String,
    pub title: String,
    pub link: String,
    pub width: Option<String>,
    pub height: Option<String>,
    pub description: Option<String>,
}
Expand description

Represents an image in an RSS feed.

Fields§

§url: String

The URL of the image.

§title: String

A description of the image. This is used in the HTML alt attribute.

§link: String

The URL that the image links to.

§width: Option<String>

The width of the image.

§height: Option<String>

The height of the image.

§description: Option<String>

The text for the HTML title attribute of the link formed around the image.

Implementations§

source§

impl Image

source

pub fn url(&self) -> &str

Return the URL of this image.

Examples
use rss::Image;

let mut image = Image::default();
image.set_url("http://example.com/image.png");
assert_eq!(image.url(), "http://example.com/image.png");
source

pub fn set_url<V>(&mut self, url: V)where V: Into<String>,

Set the URL of this image.

Examples
use rss::Image;

let mut image = Image::default();
image.set_url("http://example.com/image.png");
source

pub fn title(&self) -> &str

Return the description of this image.

This is used in the HTML alt attribute.

Examples
use rss::Image;

let mut image = Image::default();
image.set_title("Example image");
assert_eq!(image.title(), "Example image");
source

pub fn set_title<V>(&mut self, title: V)where V: Into<String>,

Set the description of this image.

This is used in the HTML alt attribute.

Examples
use rss::Image;

let mut image = Image::default();
image.set_title("Example image");

Return the URL that this image links to.

Examples
use rss::Image;

let mut image = Image::default();
image.set_link("http://example.com");
assert_eq!(image.link(), "http://example.com");

Set the URL that this image links to.

Examples
use rss::Image;

let mut image = Image::default();
image.set_link("http://example.com");
source

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

Return the width of this image.

If the width is None the default value should be considered to be 80.

Examples
use rss::Image;

let mut image = Image::default();
image.set_width("80".to_string());
assert_eq!(image.width(), Some("80"));
source

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

Set the width of this image.

Examples
use rss::Image;

let mut image = Image::default();
image.set_width("80".to_string());
source

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

Return the height of this image.

If the height is None the default value should be considered to be 31.

Examples
use rss::Image;

let mut image = Image::default();
image.set_height("31".to_string());
assert_eq!(image.height(), Some("31"));
source

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

Set the height of this image.

If the height is None the default value should be considered to be 31.

Examples
use rss::Image;

let mut image = Image::default();
image.set_height("31".to_string());
source

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

Return the title for the link formed around this image.

Examples
use rss::Image;

let mut image = Image::default();
image.set_description("Example Title".to_string());
assert_eq!(image.description(), Some("Example Title"));
source

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

Set the title for the link formed around this image.

Examples
use rss::Image;

let mut image = Image::default();
image.set_description("Example Title".to_string());
source§

impl Image

source

pub fn from_xml<R: BufRead>( reader: &mut Reader<R>, _: Attributes<'_> ) -> Result<Self, Error>

Builds an Image from source XML

Trait Implementations§

source§

impl Clone for Image

source§

fn clone(&self) -> Image

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 Image

source§

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

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

impl Default for Image

source§

fn default() -> Image

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

impl<'de> Deserialize<'de> for Image

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Image

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Image

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Validate for Image

source§

fn validate(&self) -> Result<(), ValidationError>

Validate the data against the RSS specification.
source§

impl StructuralPartialEq for Image

Auto Trait Implementations§

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,