#atom-feed #feed #atom #parser

atom_syndication

Library for serializing the Atom web content syndication format

31 releases

0.12.5 Nov 16, 2024
0.12.3 May 11, 2024
0.12.2 Jul 26, 2023
0.12.1 Mar 27, 2023
0.1.1 May 22, 2015

#73 in Parser implementations

Download history 3921/week @ 2024-08-23 4448/week @ 2024-08-30 3783/week @ 2024-09-06 4395/week @ 2024-09-13 3821/week @ 2024-09-20 3907/week @ 2024-09-27 3071/week @ 2024-10-04 3565/week @ 2024-10-11 3748/week @ 2024-10-18 3966/week @ 2024-10-25 4195/week @ 2024-11-01 3604/week @ 2024-11-08 4801/week @ 2024-11-15 4721/week @ 2024-11-22 4756/week @ 2024-11-29 4111/week @ 2024-12-06

18,958 downloads per month
Used in 40 crates (27 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.57.0 or greater.

Usage

Add the dependency to your Cargo.toml.

[dependencies]
atom_syndication = "0.12"

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

[dependencies]
atom_syndication = { version = "0.12", 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.

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

~6MB
~164K SLoC