Skip to main content

rama_http/protocols/rss/
mod.rs

1//! RSS 2.0 and Atom 1.0 feed support.
2//!
3//! ## Building feeds
4//!
5//! Both formats use type-state builders that enforce required fields at
6//! compile time.  Call `.build()` only after all required fields are set.
7//!
8//! ```rust,ignore
9//! use rama_http::protocols::rss::{Rss2Feed, Rss2Item, Rss2Guid};
10//!
11//! let feed = Rss2Feed::builder()
12//!     .title("My Blog")
13//!     .link("https://example.com")
14//!     .description("Latest posts")
15//!     .item(
16//!         Rss2Item::new()
17//!             .with_title("Hello World")
18//!             .with_guid(Rss2Guid::permalink("https://example.com/1")),
19//!     )
20//!     .build();
21//! ```
22//!
23//! ## Serving feeds
24//!
25//! All feed types implement `IntoResponse`.  The correct `Content-Type`
26//! header (`application/rss+xml` or `application/atom+xml`) is set
27//! automatically.
28//!
29//! ## Parsing feeds
30//!
31//! Use [`Feed::from_body`] (or [`FeedStream::from_body`] for true streaming
32//! item-by-item processing) to parse a feed from an HTTP response. There is
33//! no sync top-level parser — everything goes through the async streaming
34//! reader.
35//!
36//! ## Streaming
37//!
38//! [`Rss2StreamWriter`] and [`AtomStreamWriter`] wrap an async item stream and
39//! produce a streaming `Body` without buffering the full document.
40//!
41//! ## Extensions
42//!
43//! All extension fields are in the [`feed_ext`] sub-module.  Items expose
44//! inherent shortcuts (`.itunes()`, `.podcast()`, `.dublin_core()`,
45//! `.content()`, `.media()`, `.podlove()`) for the six supported
46//! namespaces: iTunes, Podcasting 2.0, Dublin Core, `content:encoded`,
47//! Media RSS, and Podlove Simple Chapters (item-level only).
48
49pub mod feed_ext;
50
51mod atom;
52mod error;
53mod feed;
54mod ns;
55mod parse_util;
56mod rss2;
57mod ser;
58mod stream;
59
60pub use error::{
61    AtomCollectError, CollectError, FeedCollectError, FeedParseError, Rss2CollectError,
62};
63
64// ---------------------------------------------------------------------------
65// Re-exports: RSS 2.0
66// ---------------------------------------------------------------------------
67
68pub use rss2::{
69    Missing, Present, Rss2Category, Rss2Channel, Rss2Enclosure, Rss2Feed, Rss2FeedBuilder,
70    Rss2FeedStream, Rss2Guid, Rss2Image, Rss2Item, Rss2Source,
71};
72
73// ---------------------------------------------------------------------------
74// Re-exports: Atom 1.0
75// ---------------------------------------------------------------------------
76
77pub use atom::{
78    AtomCategory, AtomContent, AtomEntry, AtomFeed, AtomFeedBuilder, AtomFeedStream, AtomGenerator,
79    AtomHeader, AtomLink, AtomPerson, AtomSource, AtomText, AtomTextKind,
80};
81
82// ---------------------------------------------------------------------------
83// Re-exports: Feed umbrella, parsing, streaming
84// ---------------------------------------------------------------------------
85
86pub use feed::{EnclosureView, Feed, FeedItem, ItemIdView};
87pub use stream::{AtomStreamWriter, FeedStream, FeedStreamWriter, Rss2StreamWriter};
88
89// ---------------------------------------------------------------------------
90// Re-exports: Extensions
91// ---------------------------------------------------------------------------
92
93pub use feed_ext::{
94    Content, DublinCore, DublinCoreFeed, FeedExtensions, ITunes, ITunesFeed, ItemExtensions,
95    MediaContent, MediaRss, MediaThumbnail, Podcast, PodcastAlternateEnclosure, PodcastChapters,
96    PodcastEpisode, PodcastFeed, PodcastFunding, PodcastIntegrity, PodcastLocation, PodcastPerson,
97    PodcastRemoteItem, PodcastSeason, PodcastSoundbite, PodcastSource, PodcastTrailer,
98    PodcastTranscript, PodloveChapter, PodloveChapters,
99};