pub struct Parser { /* private fields */ }
Expand description
Parser for various feed formats
Implementations§
source§impl Parser
impl Parser
sourcepub fn parse<R: Read>(&self, source: R) -> ParseFeedResult<Feed>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more