Expand description
Atom 1.0 feed generation, validation, and feed-format detection. Atom 1.0 feed generation, validation, and format detection.
This module implements the subset of RFC 4287
needed to author syndication feeds in the Atom 1.0 format alongside the
existing RSS support. It is fully independent of the RSS code path: callers
that want Atom output construct an AtomFeed, add AtomEntry values
via the builder API, and serialize through generate_atom.
It also exposes FeedFormat and detect_feed_format for callers that
need to dispatch between RSS and Atom inputs without parsing the whole
document.
§Required elements (RFC 4287 §4.1.1 & §4.1.2)
<feed>:id,title,updatedare required.<entry>:id,title,updatedare required.
Validation in this module enforces those required elements and prefixes
reported errors with feed. / entry.<idx>. to stay consistent with the
contextual validation errors introduced for the RSS path in issue #34.
§Example
use rss_gen::atom::{generate_atom, AtomEntry, AtomFeed};
let feed = AtomFeed::new()
.id("https://example.com/feed")
.title("Example Feed")
.updated("2026-06-27T00:00:00Z")
.author_name("Jane Doe")
.self_link("https://example.com/atom.xml")
.add_entry(
AtomEntry::new()
.id("https://example.com/post-1")
.title("First Post")
.updated("2026-06-27T00:00:00Z")
.summary("Hello, Atom"),
);
let xml = generate_atom(&feed).unwrap();
assert!(xml.contains(r#"<feed xmlns="http://www.w3.org/2005/Atom">"#));Structs§
- Atom
Entry - An Atom 1.0 entry (
<entry>). - Atom
Feed - An Atom 1.0 feed (
<feed>) document. - Atom
Link - An Atom
<link>element per RFC 4287 §4.2.7. - Atom
Person - A person reference (
<author>/<contributor>) per RFC 4287 §3.2.
Enums§
- Atom
Text Type - Text content for
<title>,<summary>,<content>per RFC 4287 §3.1. - Feed
Format - Discriminates between supported feed formats.
Constants§
- ATOM_
NAMESPACE - Atom 1.0 namespace literal used on the root
<feed>element.
Functions§
- detect_
feed_ format - Peeks the root element of an XML document and returns the detected
FeedFormat. - generate_
atom - Serializes an
AtomFeedinto an Atom 1.0 XML string.