GithubHelp home page GithubHelp logo

crmaxx / atom Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-syndication/atom

0.0 3.0 0.0 70 KB

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

License: Apache License 2.0

Rust 100.00%

atom's Introduction

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.

atom's People

Contributors

andete avatar andy128k avatar bors[bot] avatar djc avatar frewsxcv avatar jameshurst avatar themasch avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.