Skip to main content

Module atom

Module atom 

Source
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, updated are required.
  • <entry>: id, title, updated are 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§

AtomEntry
An Atom 1.0 entry (<entry>).
AtomFeed
An Atom 1.0 feed (<feed>) document.
AtomLink
An Atom <link> element per RFC 4287 §4.2.7.
AtomPerson
A person reference (<author> / <contributor>) per RFC 4287 §3.2.

Enums§

AtomTextType
Text content for <title>, <summary>, <content> per RFC 4287 §3.1.
FeedFormat
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 AtomFeed into an Atom 1.0 XML string.