facet-atom
Provides strongly-typed Atom Syndication Format (RFC 4287) parsing and generation using facet-xml.
Why facet-atom?
Atom is the standard XML-based format for web content syndication. While RSS is more widely known, Atom (RFC 4287) offers a cleaner, more precisely specified format that's used by many content platforms, feed readers, and publishing tools.
facet-atom provides strongly-typed, compile-time-safe Atom structures derived from Facet's reflection system. You get:
- Full RFC 4287 Compliance: All standard elements and constructs are supported
- Type Safety: The Rust compiler catches mismatches between your Atom structure and actual data
- Zero Dependencies: Built on facet-xml, which uses only quick-xml for parsing
- Bidirectional: Both parsing and generation are supported with consistent types
This makes facet-atom ideal for:
- Feed aggregators and readers
- Publishing systems that generate Atom feeds
- Content syndication pipelines
- Feed validation and transformation tools
Supported Elements
The following Atom elements are fully supported:
Container Elements
<feed>: Top-level feed container with metadata and entries<entry>: Individual content entries<source>: Original feed metadata for aggregated entries
Metadata Elements
<author>/<contributor>: Person constructs with name, uri, email<category>: Categorization with term, scheme, label<generator>: Feed generator information<icon>/<logo>: Feed imagery<link>: Related resources with full attribute support (href, rel, type, hreflang, title, length)<id>: Permanent, universally unique identifiers
Content Elements
<title>/<subtitle>/<summary>/<rights>: Text constructs supporting text/html/xhtml<content>: Entry content (inline or external via src)<published>/<updated>: RFC 3339 timestamps
Basic Usage
use ;
// Parse an Atom feed
let xml = r#"<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<updated>2003-12-13T18:30:02Z</updated>
<author>
<name>John Doe</name>
</author>
<entry>
<title>First Post</title>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2003-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
</entry>
</feed>"#;
let feed: Feed = from_str?;
assert_eq!;
Features
- Full RFC 4287 support: All standard elements and attributes
- Text construct types: Plain text, escaped HTML, and inline XHTML
- Namespace handling: Proper Atom namespace (
http://www.w3.org/2005/Atom) - Roundtrip support: Parse and regenerate valid Atom XML
- Link relations: Support for alternate, self, enclosure, related, via, and custom relations
References
Part of the Facet Ecosystem
This crate is part of the facet ecosystem, providing reflection for Rust.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.