feed_rs::parser

Struct Parser

source
pub struct Parser { /* private fields */ }
Expand description

Parser for various feed formats

Implementations§

source§

impl Parser

source

pub fn parse<R: Read>(&self, source: R) -> ParseFeedResult<Feed>

Parse the input (Atom, a flavour of RSS or JSON Feed) into our model

§Arguments
  • input - A source of content such as a string, file etc.

NOTE: feed-rs uses the encoding attribute in the XML prolog to decode content. HTTP libraries (such as reqwest) provide a text() method which applies the content-encoding header and decodes the source into UTF-8. This then causes feed-rs to fail when it attempts to interpret the UTF-8 stream as a different character set. Instead, pass the raw, encoded source to feed-rs e.g. the .bytes() method if using reqwest.

§Examples
use feed_rs::parser;
let xml = r#"
<feed>
   <title type="text">sample feed</title>
   <updated>2005-07-31T12:29:29Z</updated>
   <id>feed1</id>
   <entry>
       <title>sample entry</title>
       <id>entry1</id>
   </entry>
</feed>
"#;
let feed_from_xml = parser::parse(xml.as_bytes()).unwrap();

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl !RefUnwindSafe for Parser

§

impl !Send for Parser

§

impl !Sync for Parser

§

impl Unpin for Parser

§

impl !UnwindSafe for Parser

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> 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, 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.