Skip to content
/ atom Public
forked from rust-syndication/atom

Library for serializing the Atom web content syndication format https://crates.io/crates/atom_syndication

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

crmaxx/atom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atom

Build Status Crates.io Status

Library for serializing the Atom web content syndication format.

Documentation

Usage

Add the dependency to your Cargo.toml.

[dependencies]
atom_syndication = "0.5"

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.

About

Library for serializing the Atom web content syndication format https://crates.io/crates/atom_syndication

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%