#atom #feed #parser #parsing

atom_syndication

Library for serializing the Atom web content syndication format

24 releases

0.10.0 Jun 6, 2021
0.9.1 Jan 7, 2021
0.9.0 May 13, 2020
0.8.0 Jan 23, 2020
0.1.1 May 22, 2015

#33 in Parser implementations

Download history 798/week @ 2021-02-24 543/week @ 2021-03-03 745/week @ 2021-03-10 723/week @ 2021-03-17 890/week @ 2021-03-24 945/week @ 2021-03-31 1281/week @ 2021-04-07 805/week @ 2021-04-14 691/week @ 2021-04-21 544/week @ 2021-04-28 588/week @ 2021-05-05 388/week @ 2021-05-12 557/week @ 2021-05-19 844/week @ 2021-05-26 850/week @ 2021-06-02 735/week @ 2021-06-09

3,136 downloads per month
Used in 15 crates (13 directly)

MIT/Apache

120KB
2K SLoC

atom

Build status Crates.io Status Coverage

Library for serializing the Atom web content syndication format.

Documentation

This crate requires Rustc version 1.40.0 or greater.

Usage

Add the dependency to your Cargo.toml.

[dependencies]
atom_syndication = "0.10"

Or, if you want Serde include the feature like this:

[dependencies]
atom_syndication = { version = "0.10", features = ["with-serde"] }

The package includes a single crate named atom_syndication.

extern crate atom_syndication;

Reading

A feed can be read from any object that implements the BufRead trait or using the FromStr trait.

use std::fs::File;
use std::io::BufReader;
use atom_syndication::Feed;

let file = File::open("example.xml").unwrap();
let feed = Feed::read_from(BufReader::new(reader)).unwrap();

let string = "<feed></feed>";
let feed = string.parse::<Feed>().unwrap();

Writing

A feed can be written to any object that implements the Write trait or converted to an XML string using the ToString trait.

Note: Writing a feed does not perform any escaping of XML entities.

Example

use std::fs::File;
use std::io::{BufReader, sink};
use atom_syndication::Feed;

let file = File::open("example.xml").unwrap();
let feed = Feed::read_from(BufReader::new(file)).unwrap();

// write to the feed to a writer
feed.write_to(sink()).unwrap();

// convert the feed to a string
let string = feed.to_string();

Invalid Feeds

As a best effort to parse invalid feeds atom_syndication will default elements declared as "required" by the Atom specification to an empty string.

License

Licensed under either of

at your option.

Dependencies

~5MB
~155K SLoC