#atom #feed #parser #parsing

atom_syndication

Library for serializing the Atom web content syndication format

26 releases

Uses new Rust 2021

0.12.0 Dec 29, 2022
0.11.0 Oct 20, 2021
0.10.0 Jun 6, 2021
0.9.1 Jan 7, 2021
0.1.1 May 22, 2015

#370 in Parser implementations

Download history 1691/week @ 2022-10-07 885/week @ 2022-10-14 1160/week @ 2022-10-21 2254/week @ 2022-10-28 1897/week @ 2022-11-04 1541/week @ 2022-11-11 1556/week @ 2022-11-18 1693/week @ 2022-11-25 922/week @ 2022-12-02 1225/week @ 2022-12-09 1105/week @ 2022-12-16 1175/week @ 2022-12-23 2914/week @ 2022-12-30 1537/week @ 2023-01-06 1617/week @ 2023-01-13 1735/week @ 2023-01-20

8,076 downloads per month
Used in 21 crates (17 directly)

MIT/Apache

135KB
2.5K SLoC

atom

Build status Crates.io Status Coverage

Library for serializing the Atom web content syndication format.

Documentation

This crate requires Rustc version 1.56.0 or greater.

Usage

Add the dependency to your Cargo.toml.

[dependencies]
atom_syndication = "0.11"

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

[dependencies]
atom_syndication = { version = "0.11", 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(file)).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

~5.5MB
~158K SLoC