https://github.com/rust-syndication/atom
Library for serializing the Atom web content syndication format https://crates.io/crates/atom_syndication
https://github.com/rust-syndication/atom
atom feed parser rust
Last synced: about 1 month ago
JSON representation
Library for serializing the Atom web content syndication format https://crates.io/crates/atom_syndication
- Host: GitHub
- URL: https://github.com/rust-syndication/atom
- Owner: rust-syndication
- License: apache-2.0
- Created: 2017-06-24T00:40:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-21T00:30:15.000Z (over 1 year ago)
- Last Synced: 2024-07-18T09:57:30.972Z (over 1 year ago)
- Topics: atom, feed, parser, rust
- Language: Rust
- Size: 183 KB
- Stars: 83
- Watchers: 2
- Forks: 22
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# atom
[](https://github.com/rust-syndication/atom/actions)
[](https://crates.io/crates/atom_syndication)
[](https://codecov.io/gh/rust-syndication/atom/)
Library for serializing the Atom web content syndication format.
[Documentation](https://docs.rs/atom_syndication/)
This crate requires *Rustc version 1.83.0 or greater*.
## Usage
Add the dependency to your `Cargo.toml`.
```toml
[dependencies]
atom_syndication = "0.12"
```
Or, if you want [Serde](https://github.com/serde-rs/serde) include the feature like this:
```toml
[dependencies]
atom_syndication = { version = "0.12", features = ["with-serde"] }
```
The package includes a single crate named `atom_syndication`.
```rust
extern crate atom_syndication;
```
## Reading
A feed can be read from any object that implements the `BufRead` trait or using the `FromStr` trait.
```rust
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 = "";
let feed = string.parse::().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
```rust
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
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.