Skip to main content

Module rss

Module rss 

Available on crate features http and rss only.
Expand description

RSS 2.0 and Atom 1.0 feed support.

§Building feeds

Both formats use type-state builders that enforce required fields at compile time. Call .build() only after all required fields are set.

use rama_http::protocols::rss::{Rss2Feed, Rss2Item, Rss2Guid};

let feed = Rss2Feed::builder()
    .title("My Blog")
    .link("https://example.com")
    .description("Latest posts")
    .item(
        Rss2Item::new()
            .with_title("Hello World")
            .with_guid(Rss2Guid::permalink("https://example.com/1")),
    )
    .build();

§Serving feeds

All feed types implement IntoResponse. The correct Content-Type header (application/rss+xml or application/atom+xml) is set automatically.

§Parsing feeds

Use Feed::from_body (or FeedStream::from_body for true streaming item-by-item processing) to parse a feed from an HTTP response. There is no sync top-level parser — everything goes through the async streaming reader.

§Streaming

Rss2StreamWriter and AtomStreamWriter wrap an async item stream and produce a streaming Body without buffering the full document.

§Extensions

All extension fields are in the feed_ext sub-module. Items expose inherent shortcuts (.itunes(), .podcast(), .dublin_core(), .content(), .media(), .podlove()) for the six supported namespaces: iTunes, Podcasting 2.0, Dublin Core, content:encoded, Media RSS, and Podlove Simple Chapters (item-level only).

Modules§

feed_ext
RSS/Atom feed extension system.

Structs§

AtomCategory
An Atom category element.
AtomContent
An Atom <content> element.
AtomEntry
An Atom entry.
AtomFeed
An Atom feed.
AtomFeedBuilder
Type-state builder for AtomFeed.
AtomFeedStream
Async streaming reader for an Atom 1.0 feed.
AtomGenerator
An Atom generator element.
AtomHeader
Feed-level metadata of an Atom 1.0 document — everything an AtomFeed carries except its entries.
AtomLink
An Atom link element.
AtomPerson
An Atom person construct.
AtomSource
An Atom source element (entry’s original feed metadata).
AtomStreamWriter
Strongly-typed Atom 1.0 stream writer. Mirror of Rss2StreamWriter.
AtomText
Atom text construct: a string body plus a AtomTextKind that says how to interpret/serialize it. Equivalent of the spec’s “Text Construct” (RFC 4287 §3.1).
CollectError
Returned by Rss2FeedStream::collect, AtomFeedStream::collect and FeedStream::collect when an item / entry fails to parse partway through the stream. The partial feed holds the header that was parsed at stream construction and every item / entry that succeeded before the failure, so callers can keep what’s salvageable.
Content
content:encoded extension — carries full HTML/XHTML body for a feed item.
DublinCore
Dublin Core extension fields for a feed item.
DublinCoreFeed
Dublin Core extension fields at the feed (channel) level.
EnclosureView
Normalised view over an enclosure: RSS <enclosure> and Atom <link rel="enclosure"> collapse to the same (url, length, mime) shape. length and mime are required by RSS but optional in Atom.
FeedExtensions
Extension container for feeds (channel-level for RSS 2.0, feed-level for Atom).
FeedParseError
Returned when the document cannot be turned into a feed at all — either nothing recognisable as an RSS 2.0 / Atom 1.0 root was seen, or strict mode rejected a structural violation in the header.
FeedStreamWriter
Format-agnostic stream writer. Use this when the caller has a Feed (often from a super::FeedStream::collect) and wants to re-emit it without first checking which variant it is. Internally type-erased into a BoxStream<Bytes>.
ITunes
iTunes extension fields for a single podcast episode item.
ITunesFeed
iTunes extension fields at the feed (channel) level.
ItemExtensions
Extension container for feed items (RSS 2.0 items and Atom entries).
MediaContent
A single media:content element.
MediaRss
Media RSS extension for a feed item.
MediaThumbnail
A media:thumbnail element.
Podcast
Podcasting 2.0 extension fields for a single episode item.
PodcastChapters
A podcast:chapters reference.
PodcastEpisode
A podcast:episode element.
PodcastFeed
Podcasting 2.0 extension fields at the feed (channel) level.
PodcastFunding
A podcast:funding element (feed-level).
PodcastLocation
A podcast:location element.
PodcastPerson
A podcast:person element (used at both item and feed level).
PodcastRemoteItem
A podcast:remoteItem element (feed-level).
PodcastSeason
A podcast:season element.
PodcastSoundbite
A podcast:soundbite element. Podcasting 2.0 spec uses decimal seconds for both start and duration (sub-second precision is meaningful).
PodcastTrailer
A podcast:trailer element (feed-level).
PodcastTranscript
A podcast:transcript element.
PodloveChapter
A single <psc:chapter> element.
PodloveChapters
A <psc:chapters> element. Item-level only (a chapter list applies to a single episode).
Rss2Category
RSS 2.0 category element.
Rss2Channel
Channel-level metadata of an RSS 2.0 feed — everything an Rss2Feed carries except its items. Re-combine with item events via Rss2Channel::into_feed_with_items.
Rss2Enclosure
RSS 2.0 enclosure element.
Rss2Feed
An RSS 2.0 feed.
Rss2FeedBuilder
Type-state builder for Rss2Feed.
Rss2FeedStream
Async streaming reader for an RSS 2.0 feed.
Rss2Guid
RSS 2.0 guid element.
Rss2Image
RSS 2.0 image element.
Rss2Item
An RSS 2.0 channel item.
Rss2Source
RSS 2.0 source element.
Rss2StreamWriter
Strongly-typed RSS 2.0 stream writer.

Enums§

AtomTextKind
Which Atom type= attribute applies to an AtomText.
Feed
A feed in either RSS 2.0 or Atom 1.0 format.
FeedItem
One item or entry, regardless of the originating feed format. Yielded by FeedStream when iterated as a Stream; convert into a strongly-typed Rss2Item / AtomEntry with the obvious match, or use the cross-format accessors directly on this enum.
FeedStream
One async stream per supported feed format. Use FeedStream::new when the input format isn’t known ahead of time, or Rss2FeedStream / AtomFeedStream directly when it is.

Type Aliases§

AtomCollectError
Per-format convenience alias.
FeedCollectError
Format-agnostic alias.
Rss2CollectError
Per-format convenience alias.