rss_for_mikan/lib.rs
1// This file is part of rss.
2//
3// Copyright © 2015-2021 The rust-syndication Developers
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the MIT License and/or Apache 2.0 License.
7
8#![warn(missing_docs)]
9#![doc(html_root_url = "https://docs.rs/rss/")]
10
11//! Library for serializing the RSS web content syndication format.
12//!
13//! # Reading
14//!
15//! A channel can be read from any object that implements the `BufRead` trait.
16//!
17//! ## From a file
18//!
19//! ```rust,no_run
20//! use std::fs::File;
21//! use std::io::BufReader;
22//! use rss::Channel;
23//!
24//! let file = File::open("example.xml").unwrap();
25//! let channel = Channel::read_from(BufReader::new(file)).unwrap();
26//! ```
27//!
28//! ### From a buffer
29//!
30//! **Note**: This example requires [reqwest](https://crates.io/crates/reqwest) crate.
31//!
32//! ```rust,ignore
33//! use std::error::Error;
34//! use rss::Channel;
35//!
36//! async fn example_feed() -> Result<Channel, Box<dyn Error>> {
37//! let content = reqwest::get("http://example.com/feed.xml")
38//! .await?
39//! .bytes()
40//! .await?;
41//! let channel = Channel::read_from(&content[..])?;
42//! Ok(channel)
43//! }
44//! ```
45//!
46//! # Writing
47//!
48//! A channel can be written to any object that implements the `Write` trait or converted to an
49//! XML string using the `ToString` trait.
50//!
51//! **Note**: Writing a channel does not perform any escaping of XML entities.
52//!
53//! ```rust
54//! use rss::Channel;
55//!
56//! let channel = Channel::default();
57//! channel.write_to(::std::io::sink()).unwrap(); // write to the channel to a writer
58//! let string = channel.to_string(); // convert the channel to a string
59//! ```
60//!
61//! # Creation
62//!
63//! Builder methods are provided to assist in the creation of channels.
64//!
65//! **Note**: This requires the `builders` feature, which is enabled by default.
66//!
67//! ```
68//! use rss::ChannelBuilder;
69//!
70//! let channel = ChannelBuilder::default()
71//! .title("Channel Title")
72//! .link("http://example.com")
73//! .description("An RSS feed.")
74//! .build();
75//! ```
76//!
77//! ## Validation
78//!
79//! Validation methods are provided to validate the contents of a channel against the
80//! RSS specification.
81//!
82//! **Note**: This requires enabling the `validation` feature.
83//!
84//! ```rust,ignore
85//! use rss::Channel;
86//! use rss::validation::Validate;
87//!
88//! let channel = Channel::default();
89//! channel.validate().unwrap();
90//! ```
91
92#[cfg(feature = "builders")]
93#[macro_use]
94extern crate derive_builder;
95
96extern crate quick_xml;
97
98#[cfg(feature = "serde")]
99#[cfg(feature = "validation")]
100extern crate chrono;
101#[cfg(feature = "validation")]
102extern crate mime;
103#[cfg(feature = "serde")]
104#[macro_use]
105extern crate serde;
106#[cfg(feature = "validation")]
107extern crate url;
108
109mod category;
110mod channel;
111mod cloud;
112mod enclosure;
113mod guid;
114mod image;
115mod item;
116mod source;
117mod textinput;
118
119mod error;
120mod toxml;
121mod util;
122
123/// Types and methods for namespaced extensions.
124pub mod extension;
125
126/// Methods for validating RSS feeds.
127#[cfg(feature = "validation")]
128pub mod validation;
129
130pub use crate::category::Category;
131#[cfg(feature = "builders")]
132pub use crate::category::CategoryBuilder;
133pub use crate::channel::Channel;
134#[cfg(feature = "builders")]
135pub use crate::channel::ChannelBuilder;
136pub use crate::cloud::Cloud;
137#[cfg(feature = "builders")]
138pub use crate::cloud::CloudBuilder;
139pub use crate::enclosure::Enclosure;
140#[cfg(feature = "builders")]
141pub use crate::enclosure::EnclosureBuilder;
142pub use crate::guid::Guid;
143#[cfg(feature = "builders")]
144pub use crate::guid::GuidBuilder;
145pub use crate::image::Image;
146#[cfg(feature = "builders")]
147pub use crate::image::ImageBuilder;
148pub use crate::item::Item;
149#[cfg(feature = "builders")]
150pub use crate::item::ItemBuilder;
151pub use crate::source::Source;
152#[cfg(feature = "builders")]
153pub use crate::source::SourceBuilder;
154pub use crate::textinput::TextInput;
155#[cfg(feature = "builders")]
156pub use crate::textinput::TextInputBuilder;
157
158pub use crate::error::Error;