### GUID as Permalink Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Shows how to create a Guid instance where the value is a URL and permalink is set to true. ```rust use rss::Guid; let guid = Guid { value: "https://example.com/articles/12345".to_string(), permalink: true, // This is the permanent URL }; assert!(guid.is_permalink()); ``` -------------------------------- ### GUID as Permalink Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Illustrates creating a Guid that functions as a permalink, using a URL as its value. ```APIDOC ## GUID as permalink Illustrates creating a Guid that functions as a permalink, using a URL as its value. ```rust use rss::Guid; let guid = Guid { value: "https://example.com/articles/12345".to_string(), permalink: true, // This is the permanent URL }; assert!(guid.is_permalink()); ``` ``` -------------------------------- ### Different Guid Formats Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Provides examples of creating Guid instances for different formats: UUID, URL permalink, and a custom string identifier. ```rust use rss::Guid; // UUID format let uuid_guid = Guid { value: "f47ac10b-58cc-4372-a567-0e02b2c3d479".to_string(), permalink: false, }; // URL format with permalink let url_guid = Guid { value: "https://news.example.com/article/2024/001".to_string(), permalink: true, }; // Custom format let custom_guid = Guid { value: "article-123-rev-2024-01-15".to_string(), permalink: false, }; ``` -------------------------------- ### GUID as UUID Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Demonstrates how to create and use a Guid when it represents a UUID and is not a permalink. ```APIDOC ## GUID as UUID Demonstrates how to create and use a Guid when it represents a UUID and is not a permalink. ```rust use rss::Guid; let guid = Guid { value: "550e8400-e29b-41d4-a716-446655440000".to_string(), permalink: false, // Not a URL, just an identifier }; assert_eq!(guid.value(), "550e8400-e29b-41d4-a716-446655440000"); assert!(!guid.is_permalink()); ``` ``` -------------------------------- ### GUID as UUID Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Demonstrates creating a Guid instance with a UUID string and setting permalink to false, indicating it's just an identifier. ```rust use rss::Guid; let guid = Guid { value: "550e8400-e29b-41d4-a716-446655440000".to_string(), permalink: false, // Not a URL, just an identifier }; assert_eq!(guid.value(), "550e8400-e29b-41d4-a716-446655440000"); assert!(!guid.is_permalink()); ``` -------------------------------- ### Using Guid Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Illustrates creating a Guid instance using the builder pattern, setting the value and permalink status. ```rust use rss::GuidBuilder; let guid = GuidBuilder::default() .value("article-2024-001") .permalink(false) .build(); ``` -------------------------------- ### Cloud Validation Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/cloud.md Demonstrates how to create and validate a Cloud object. This example requires the 'validation' feature. ```rust use rss::Cloud; use rss::validation::Validate; let cloud = Cloud { domain: "http://rpc.example.com".to_string(), port: "80".to_string(), path: "/rpc".to_string(), register_procedure: "pingMe".to_string(), protocol: "xml-rpc".to_string(), }; cloud.validate()?; // OK ``` -------------------------------- ### Minimal Complete Example: Create, Write, and Read RSS Channel Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/overview.md A minimal example demonstrating the creation of an RSS channel using `ChannelBuilder`, writing it to a byte vector, and then reading it back to verify. ```rust use rss::ChannelBuilder; use std::io::Cursor; fn main() -> Result<(), Box> { // Create a channel let channel = ChannelBuilder::default() .title("My Blog") .link("https://example.com") .description("My thoughts on technology") .build(); // Write to bytes let mut buf = Vec::new(); channel.write_to(&mut buf)?; // Read it back let parsed = rss::Channel::read_from(Cursor::new(&buf))?; println!("Successfully created and parsed: {}", parsed.title()); Ok(()) } ``` -------------------------------- ### Source Validation Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Demonstrates how to validate a Source instance. This example requires the 'validation' feature to be enabled. ```rust use rss::Source; use rss::validation::Validate; let source = Source { url: "https://original-blog.com/feed".to_string(), title: Some("Original Tech Blog".to_string()), }; source.validate()?; // OK ``` -------------------------------- ### Using Builder for Guid Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Shows how to construct a Guid object using the builder pattern. ```APIDOC ## Using builder Shows how to construct a Guid object using the builder pattern. ```rust use rss::GuidBuilder; let guid = GuidBuilder::default() .value("article-2024-001") .permalink(false) .build(); ``` ``` -------------------------------- ### Basic Podcast Enclosure Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/enclosure.md Creates a basic audio enclosure for a podcast episode. ```rust use rss::Enclosure; let enclosure = Enclosure { url: "https://example.com/podcast/episode1.mp3".to_string(), length: "45000000".to_string(), // ~43 MB mime_type: "audio/mpeg".to_string(), }; assert_eq!(enclosure.url(), "https://example.com/podcast/episode1.mp3"); assert_eq!(enclosure.mime_type(), "audio/mpeg"); ``` -------------------------------- ### Adding Guid to an Item Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Provides an example of how to set a Guid for an RSS Item. ```APIDOC ## Adding to item Provides an example of how to set a Guid for an RSS Item. ```rust use rss::{Item, Guid}; let mut item = Item::default(); item.set_title("My Article"); let guid = Guid { value: "https://myblog.com/posts/article-123".to_string(), permalink: true, }; item.set_guid(Some(guid)); if let Some(guid) = item.guid() { println!("Item ID: {}", guid.value()); if guid.is_permalink() { println!("Permalink: Yes"); } } ``` ``` -------------------------------- ### Working with Unique Identifiers (GUIDs) Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Illustrates how to set and retrieve a Globally Unique Identifier (GUID) for an item, including whether the GUID is a permalink. ```rust use rss::{Item, Guid}; let mut item = Item::default(); item.set_title("Article with GUID"); let guid = Guid { value: "article-12345@example.com".to_string(), permalink: true, // true means the GUID is the item's permanent URL }; item.set_guid(guid); if let Some(guid) = item.guid() { println!("ID: {}", guid.value()); println!("Is Permalink: {}", guid.is_permalink()); } ``` -------------------------------- ### MimeParsing Error Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/errors.md Shows how to handle a MimeParsing error if the enclosure.mime_type is not a valid MIME type. Valid examples include "audio/mpeg", "video/mp4", and "image/png". ```rust use rss::{Enclosure, Validate}; use rss::validation::Validate; let enc = Enclosure { url: "http://example.com/file.mp3".to_string(), length: "12345".to_string(), mime_type: "not/valid/mime".to_string(), }; match enc.validate() { Err(ValidationError::MimeParsing(_)) => { eprintln!("Invalid MIME type"); } _ => {} } ``` -------------------------------- ### Adding Guid to an RSS Item Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Demonstrates how to create an RSS Item and associate a Guid (as a permalink) with it. ```rust use rss::{Item, Guid}; let mut item = Item::default(); item.set_title("My Article"); let guid = Guid { value: "https://myblog.com/posts/article-123".to_string(), permalink: true, }; item.set_guid(Some(guid)); if let Some(guid) = item.guid() { println!("Item ID: {}", guid.value()); if guid.is_permalink() { println!("Permalink: Yes"); } } ``` -------------------------------- ### Category with Domain Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/category.md Shows how to create a `Category` with a specified domain and how to access that domain using the `domain()` method. ```rust use rss::Category; let cat = Category { name: "Business".to_string(), domain: Some("http://taxonomy.example.com/categories".to_string()), }; if let Some(domain) = cat.domain() { println!("Taxonomy: {}", domain); } ``` -------------------------------- ### Different GUID Formats Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Illustrates the creation of Guids in various formats, including UUID, URL permalink, and custom string identifiers. ```APIDOC ## Different GUID formats Illustrates the creation of Guids in various formats, including UUID, URL permalink, and custom string identifiers. ```rust use rss::Guid; // UUID format let uuid_guid = Guid { value: "f47ac10b-58cc-4372-a567-0e02b2c3d479".to_string(), permalink: false, }; // URL format with permalink let url_guid = Guid { value: "https://news.example.com/article/2024/001".to_string(), permalink: true, }; // Custom format let custom_guid = Guid { value: "article-123-rev-2024-01-15".to_string(), permalink: false, }; ``` ``` -------------------------------- ### Default Guid Constructor Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Provides a default implementation for Guid, initializing with an empty value and permalink set to true. ```rust impl Default for Guid { fn default() -> Guid } ``` -------------------------------- ### Working with Unique Identifiers (GUIDs) Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Explains how to set and retrieve a Globally Unique Identifier (GUID) for an item. ```APIDOC ## Working with unique identifiers (GUIDs) ### Description This example shows how to assign a `Guid` to an `Item` and how to access its value and permalink status. ### Usage Create a `Guid` struct with a `value` and a `permalink` boolean, then set it on the `Item` using `set_guid()`. Retrieve it using `guid()`. ### Example ```rust use rss::{Item, Guid}; let mut item = Item::default(); item.set_title("Article with GUID"); let guid = Guid { value: "article-12345@example.com".to_string(), permalink: true, // true means the GUID is the item's permanent URL }; item.set_guid(guid); if let Some(guid) = item.guid() { println!("ID: {}", guid.value()); println!("Is Permalink: {}", guid.is_permalink()); } ``` ``` -------------------------------- ### Guid Constructor (Default) Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Provides a default constructor for the Guid struct, initializing it with an empty value and permalink set to true. ```APIDOC ## Default Constructor Provides a default constructor for the Guid struct, initializing it with an empty value and permalink set to true. ```rust impl Default for Guid { fn default() -> Guid } ``` **Returns:** Guid with empty value and `permalink = true` ``` -------------------------------- ### Guid Methods Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Details the available methods for interacting with the Guid struct, including getters and setters for its value and permalink status. ```APIDOC ## Methods Details the available methods for interacting with the Guid struct, including getters and setters for its value and permalink status. ### value ```rust pub fn value(&self) -> &str ``` **Returns:** The GUID value ### set_value ```rust pub fn set_value(&mut self, value: V) where V: Into ``` **Sets:** The GUID value ### is_permalink ```rust pub fn is_permalink(&self) -> bool ``` **Returns:** Whether the GUID is a permalink ### set_permalink ```rust pub fn set_permalink(&mut self, permalink: V) where V: Into ``` **Sets:** Whether the GUID is a permalink ``` -------------------------------- ### TextInput Validation Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Demonstrates how to validate a TextInput instance using the Validate trait. This example requires the 'validation' feature. ```rust use rss::TextInput; use rss::validation::Validate; let text_input = TextInput { title: "Search".to_string(), description: "Search this site".to_string(), name: "query".to_string(), link: "https://example.com/search".to_string(), }; text_input.validate()?; // OK ``` -------------------------------- ### Create and Write Full RSS Item Workflow Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Illustrates the complete process of creating an RSS channel and an item with all fields, including an enclosure and GUID, and writing it to an XML file. ```rust use rss::{Channel, Item, Enclosure, Guid}; // Create channel let mut channel = Channel::default(); channel.set_title("Podcast Feed"); channel.set_link("https://example.com"); channel.set_description("My podcast"); // Create item with all fields let mut item = Item::default(); item.set_title("Episode 1: Intro"); item.set_link("https://example.com/episode1"); item.set_description("Introduction to the podcast"); item.set_author("host@example.com"); item.set_pub_date("Mon, 01 Jan 2024 10:00:00 GMT".to_string()); // Add enclosure for audio item.set_enclosure(Enclosure { url: "https://example.com/episode1.mp3".to_string(), length: "45000000".to_string(), mime_type: "audio/mpeg".to_string(), }); // Add GUID item.set_guid(Guid { value: "ep1@example.com".to_string(), permalink: true, }); channel.set_items(vec![item]); // Write to file let file = std::fs::File::create("podcast.xml")?; channel.write_to(file)?; ``` -------------------------------- ### Different TextInput Use Cases Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Provides examples of creating TextInput instances for various purposes like newsletter subscriptions, feedback forms, and site searches. ```rust use rss::TextInput; // Newsletter subscription let newsletter = TextInput { title: "Subscribe".to_string(), description: "Enter your email to subscribe".to_string(), name: "email".to_string(), link: "https://example.com/subscribe.php".to_string(), }; // Feedback form let feedback = TextInput { title: "Send Feedback".to_string(), description: "Tell us what you think".to_string(), name: "feedback".to_string(), link: "https://example.com/feedback.cgi".to_string(), }; // Site search let search = TextInput { title: "Search".to_string(), description: "Search the entire site".to_string(), name: "keywords".to_string(), link: "https://example.com/search.php".to_string(), }; ``` -------------------------------- ### Getter/Setter Pattern for Item Fields Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/overview.md Demonstrates how to get and set optional string fields on an Item using the getter/setter pattern. Fields are accessed via Option<&str> for getting and Option or Into for setting. ```rust let mut item = Item::default(); // Get let title = item.title(); // Returns Option<&str> // Set item.set_title("New Title"); item.set_title(Some("New Title".to_string())); item.set_title(None); ``` -------------------------------- ### Enable Builders, Validation, and Atom Features Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/configuration.md Example of enabling multiple features in Cargo.toml. ```toml [dependencies] rss = { version = "2.0", features = ["builders", "validation", "atom"] } ``` -------------------------------- ### Minimal Cargo Configuration Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/configuration.md Configuration for a minimal rss crate setup, disabling all default features. ```toml rss = { version = "2.0", default-features = false } ``` -------------------------------- ### Enable Builders Feature in Cargo.toml Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/configuration.md Example of enabling only the builders feature in Cargo.toml. ```toml [dependencies] rss = { version = "2.0", features = ["builders"] } ``` -------------------------------- ### ttl Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Get the time-to-live in minutes for caching. ```APIDOC ## ttl ### Description Get the time-to-live in minutes (how long to cache before refreshing). ### Method `ttl` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```rust // Assuming 'channel' is a Channel instance let ttl_minutes = channel.ttl(); ``` ### Response #### Success Response - Returns the TTL in minutes as an `Option<&str>`. #### Response Example None provided. ``` -------------------------------- ### Enable Serde Feature in Cargo.toml Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/configuration.md Example of enabling the 'with-serde' feature in Cargo.toml for serialization and deserialization. ```toml [dependencies] rss = { version = "2.0", features = ["with-serde"] } serde_json = "1.0" ``` -------------------------------- ### Manage Item Enclosure Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Provides methods to get or set the media enclosure (e.g., podcast or media file) for an item. ```rust pub fn enclosure(&self) -> Option<&Enclosure> pub fn set_enclosure(&mut self, enclosure: V) where V: Into> ``` -------------------------------- ### docs Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Get the URL to RSS format documentation. ```APIDOC ## docs ### Description Get the URL to RSS format documentation. ### Method `docs` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```rust // Assuming 'channel' is a Channel instance let docs_url = channel.docs(); ``` ### Response #### Success Response - Returns the docs URL as an `Option<&str>`. #### Response Example None provided. ``` -------------------------------- ### Get Docs URL Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Retrieves the URL pointing to the RSS format documentation for the channel. Returns None if not set. ```rust pub fn docs(&self) -> Option<&str> ``` -------------------------------- ### Get Guid Value Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Retrieves the string value of the GUID. ```rust pub fn value(&self) -> &str ``` -------------------------------- ### Basic Category Usage Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/category.md Demonstrates the basic creation and manipulation of a `Category` object using `default`, `set_name`, and the `into` trait implementation. ```rust use rss::Category; let mut cat = Category::default(); cat.set_name("Technology"); assert_eq!(cat.name(), "Technology"); let cat2: Category = "Science".into(); // From &str assert_eq!(cat2.name(), "Science"); ``` -------------------------------- ### Working with Enclosures Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Demonstrates how to add media enclosures (like audio or video files) to an item, including URL, length, and MIME type, and how to retrieve them later. ```rust use rss::{Item, Enclosure}; let mut item = Item::default(); item.set_title("Episode 1: Getting Started"); let enclosure = Enclosure { url: "https://example.com/episode1.mp3".to_string(), length: "12345".to_string(), mime_type: "audio/mpeg".to_string(), }; item.set_enclosure(enclosure); // Later, retrieve enclosure if let Some(enc) = item.enclosure() { println!("Audio URL: {}", enc.url()); println!("Size: {} bytes", enc.length()); println!("Type: {}", enc.mime_type()); } ``` -------------------------------- ### Get Item Description Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Retrieves the summary or description of the item. Returns None if not set. ```rust pub fn description(&self) -> Option<&str> ``` -------------------------------- ### Get Cloud Path Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/cloud.md Retrieves the server path for the cloud service. ```rust pub fn path(&self) -> &str ``` -------------------------------- ### Get Source URL Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Retrieves the URL of the source channel. ```rust pub fn url(&self) -> &str ``` -------------------------------- ### Enclosures for Different Media Types Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/enclosure.md Demonstrates creating enclosures for various media types including audio, video, and PDF. ```rust use rss::Enclosure; // Audio podcast let audio = Enclosure { url: "https://example.com/episode.mp3".to_string(), length: "50000000".to_string(), mime_type: "audio/mpeg".to_string(), }; // Video podcast let video = Enclosure { url: "https://example.com/episode.mp4".to_string(), length: "500000000".to_string(), mime_type: "video/mp4".to_string(), }; // PDF document let pdf = Enclosure { url: "https://example.com/document.pdf".to_string(), length: "2000000".to_string(), mime_type: "application/pdf".to_string(), }; ``` -------------------------------- ### Manage Item GUID Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Provides methods to get or set the globally unique identifier (GUID) for an item. ```rust pub fn guid(&self) -> Option<&Guid> pub fn set_guid(&mut self, guid: V) where V: Into> ``` -------------------------------- ### Basic Cloud Usage Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/cloud.md Shows how to create and configure a Cloud object using its default constructor and setter methods. ```rust use rss::Cloud; let mut cloud = Cloud::default(); cloud.set_domain("http://rpc.example.com"); cloud.set_port("80"); cloud.set_path("/rpc"); cloud.set_register_procedure("pingMe"); cloud.set_protocol("xml-rpc"); assert_eq!(cloud.domain(), "http://rpc.example.example.com"); assert_eq!(cloud.port(), "80"); ``` -------------------------------- ### Image Validation Example Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/image.md Demonstrates how to validate an Image object using the Validate trait, checking URL validity and dimension constraints. Requires the 'validation' feature. ```rust use rss::Image; use rss::validation::Validate; let image = Image { url: "https://example.com/logo.png".to_string(), title: "Example Logo".to_string(), link: "https://example.com".to_string(), width: Some("100".to_string()), height: Some("50".to_string()), description: Some("Click for homepage".to_string()), }; image.validate()?; // OK ``` -------------------------------- ### Add Image to RSS Channel Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/image.md Demonstrates how to create an Image struct and associate it with an RSS Channel. Shows how to set image properties like URL, title, link, dimensions, and description. Also includes an example of retrieving and printing the image URL and dimensions from the channel. ```rust use rss::{Channel, Image}; let mut channel = Channel::default(); channel.set_title("My Blog"); let image = Image { url: "https://example.com/blog-header.png".to_string(), title: "Blog Header".to_string(), link: "https://example.com".to_string(), width: Some("600".to_string()), height: Some("200".to_string()), description: Some("Blog Banner".to_string()), }; channel.set_image(Some(image)); // Retrieve and display if let Some(img) = channel.image() { println!("Logo: {}", img.url()); println!("Dimensions: {}x{} px", img.width().unwrap_or("80"), img.height().unwrap_or("31")); } ``` -------------------------------- ### TextInput Methods Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Provides methods to get and set the title, description, name, and link for a TextInput. ```APIDOC ## TextInput Methods ### `title()` #### Description Returns the label for the Submit button. ### `set_title()` #### Description Sets the Submit button label. ### `description()` #### Description Returns the description text for the input. ### `set_description()` #### Description Sets the description text for the input. ### `name()` #### Description Returns the name of the text input field. ### `set_name()` #### Description Sets the name of the text input field. ### `link()` #### Description Returns the URL of the CGI script that processes the input. ### `set_link()` #### Description Sets the URL of the CGI script that processes the input. ``` -------------------------------- ### Working with Custom Extensions Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/extensions.md Illustrates how to create, set, and access custom extensions within a channel, including custom names, values, and attributes. ```rust use rss::Channel; use rss::extension::{Extension, ExtensionMap}; use std::collections::BTreeMap; let mut channel = Channel::default(); // Create a custom extension let mut custom_ext = Extension::default(); custom_ext.set_name("custom:metadata".to_string()); custom_ext.set_value(Some("Some value".to_string())); let mut attrs = BTreeMap::new(); attrs.insert("id".to_string(), "123".to_string()); custom_ext.attrs = attrs; // Add to extension map let mut inner_map = BTreeMap::new(); inner_map.insert("metadata".to_string(), vec![custom_ext]); let mut extensions = ExtensionMap::new(); extensions.insert("custom".to_string(), inner_map); channel.set_extensions(extensions); // Access custom extensions if let Some(inner) = channel.extensions().get("custom") { if let Some(elems) = inner.get("metadata") { for elem in elems { println!("Name: {}", elem.name()); if let Some(val) = elem.value() { println!("Value: {}", val); } } } } ``` -------------------------------- ### Category Methods Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/category.md Details the methods available for getting and setting the name and domain of a Category. ```APIDOC ## Category Methods ### `name()` Retrieves the category name. - **Returns:** `&str` - The category name. ### `set_name()` Sets the category name. - **Parameters:** - `name` (V): The new name for the category, convertible into a `String`. ### `domain()` Retrieves the optional domain URL for the category's taxonomy. - **Returns:** `Option<&str>` - The domain URL if specified, otherwise `None`. ### `set_domain()` Sets the domain taxonomy URL for the category. - **Parameters:** - `domain` (V): The new domain, convertible into an `Option`. ``` -------------------------------- ### Check if Guid is Permalink Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Returns a boolean indicating whether the GUID is a permalink (URL). ```rust pub fn is_permalink(&self) -> bool ``` -------------------------------- ### Manage Item Source Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Provides methods to get or set the source feed information for an item. ```rust pub fn source(&self) -> Option<&Source> pub fn set_source(&mut self, source: V) where V: Into> ``` -------------------------------- ### Guid Struct Definition Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Defines the structure of a Guid, including its value and whether it acts as a permalink. ```APIDOC ## Guid Struct Definition Defines the structure of a Guid, including its value and whether it acts as a permalink. ```rust pub struct Guid { pub value: String, pub permalink: bool, } ``` | Field | Type | Description | |-------|------|-------------| | `value` | `String` | The unique identifier value (UUID, URL, or custom ID) | | `permalink` | `bool` | If true, the GUID is a permalink (URL) to the item; if false, it's just an identifier | ``` -------------------------------- ### Working with Enclosures Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Shows how to add and retrieve enclosure information (like media files) for an item. ```APIDOC ## Working with enclosures (media/podcasts) ### Description This example demonstrates how to associate an `Enclosure` (e.g., an audio or video file) with an `Item` and how to retrieve its details. ### Usage Create an `Enclosure` struct with `url`, `length`, and `mime_type`, then set it on the `Item` using `set_enclosure()`. Retrieve it using `enclosure()`. ### Example ```rust use rss::{Item, Enclosure}; let mut item = Item::default(); item.set_title("Episode 1: Getting Started"); let enclosure = Enclosure { url: "https://example.com/episode1.mp3".to_string(), length: "12345".to_string(), mime_type: "audio/mpeg".to_string(), }; item.set_enclosure(enclosure); if let Some(enc) = item.enclosure() { println!("Audio URL: {}", enc.url()); println!("Size: {} bytes", enc.length()); println!("Type: {}", enc.mime_type()); } ``` ``` -------------------------------- ### Enable Atom Feature in Cargo.toml Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/configuration.md Example of enabling the 'atom' feature in Cargo.toml for Atom 1.0 namespace extension support. ```toml [dependencies] rss = { version = "2.0", features = ["atom"] } ``` -------------------------------- ### Setters and Getters for TextInput Fields Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Provides methods to get and set the title, description, name, and link for a TextInput. ```rust pub fn title(&self) -> &str pub fn set_title(&mut self, title: V) where V: Into pub fn description(&self) -> &str pub fn set_description(&mut self, description: V) where V: Into pub fn name(&self) -> &str pub fn set_name(&mut self, name: V) where V: Into pub fn link(&self) -> &str pub fn set_link(&mut self, link: V) where V: Into ``` -------------------------------- ### Enclosure Methods Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/enclosure.md Provides methods to get and set the URL, length, and MIME type of an enclosure. ```APIDOC ## Enclosure Methods ### Getters - **url()** -> `&str`: Returns the URL of the media file. - **length()** -> `&str`: Returns the file size in bytes as a string. - **mime_type()** -> `&str`: Returns the MIME type of the media file. ### Setters - **set_url(url: V)** where `V: Into`: Sets the URL of the media file. - **set_length(length: V)** where `V: Into`: Sets the file size in bytes. - **set_mime_type(mime_type: V)** where `V: Into`: Sets the MIME type of the media file. ``` -------------------------------- ### Set Guid Value Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Sets the string value for the GUID. Accepts any type that can be converted into a String. ```rust pub fn set_value(&mut self, value: V) where V: Into ``` -------------------------------- ### Set Guid Permalink Status Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Sets the permalink status for the GUID. Accepts any type that can be converted into a boolean. ```rust pub fn set_permalink(&mut self, permalink: V) where V: Into ``` -------------------------------- ### Basic TextInput Initialization Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Shows how to create and initialize a TextInput struct with specific values and access its fields. ```rust use rss::TextInput; let text_input = TextInput { title: "Search".to_string(), description: "Search this website".to_string(), name: "q".to_string(), link: "https://example.com/search".to_string(), }; assert_eq!(text_input.title(), "Search"); assert_eq!(text_input.name(), "q"); ``` -------------------------------- ### Image Construction with Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/image.md Demonstrates creating an Image object using the `ImageBuilder` pattern, which provides a fluent API for setting fields. ```rust use rss::ImageBuilder; let image = ImageBuilder::default() .url("https://example.com/logo.png") .title("Channel Logo") .link("https://example.com") .width("100") .height("100") .build(); ``` -------------------------------- ### Item Core Property Methods Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Provides methods to get and set core properties of an `Item`, such as title, link, description, author, comments, publication date, and content. ```APIDOC ## Core Property Methods ### title ```rust pub fn title(&self) -> Option<&str> ``` **Returns:** Item title or None ### set_title ```rust pub fn set_title(&mut self, title: V) where V: Into> ``` **Sets:** Item title ### link ```rust pub fn link(&self) -> Option<&str> ``` **Returns:** URL to the item's content or None ### set_link ```rust pub fn set_link(&mut self, link: V) where V: Into> ``` **Sets:** Item URL ### description ```rust pub fn description(&self) -> Option<&str> ``` **Returns:** Item summary/description or None ### set_description ```rust pub fn set_description(&mut self, description: V) where V: Into> ``` **Sets:** Item description ### author ```rust pub fn author(&self) -> Option<&str> ``` **Returns:** Author's email address (optional) or None ### set_author ```rust pub fn set_author(&mut self, author: V) where V: Into> ``` **Sets:** Author email address ### comments ```rust pub fn comments(&self) -> Option<&str> ``` **Returns:** URL to item's comments page or None ### set_comments ```rust pub fn set_comments(&mut self, comments: V) where V: Into> ``` **Sets:** Comments URL ### pub_date ```rust pub fn pub_date(&self) -> Option<&str> ``` **Returns:** Publication date in RFC 2822 format or None ### set_pub_date ```rust pub fn set_pub_date(&mut self, pub_date: V) where V: Into> ``` **Sets:** Publication date (RFC 2822 format or chrono timestamp with validation feature) ### content ```rust pub fn content(&self) -> Option<&str> ``` **Returns:** HTML content of the item or None ### set_content ```rust pub fn set_content(&mut self, content: V) where V: Into> ``` **Sets:** Item HTML content ``` -------------------------------- ### Channel Fields Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Provides methods to get, get mutable access to, or set the core fields of a channel. ```APIDOC ## categories ### Description Get, get mutable, or set categories for the channel. ### Methods - `categories(&self) -> &[Category]` - `categories_mut(&mut self) -> &mut [Category]` - `set_categories(&mut self, categories: V) where V: Into>` ## cloud ### Description Get or set cloud registration info for the channel. ### Methods - `cloud(&self) -> Option<&Cloud>` - `set_cloud(&mut self, cloud: V) where V: Into>` ## image ### Description Get or set the channel image. ### Methods - `image(&self) -> Option<&Image>` - `set_image(&mut self, image: V) where V: Into>` ## text_input ### Description Get or set the text input box for the channel. ### Methods - `text_input(&self) -> Option<&TextInput>` - `set_text_input(&mut self, text_input: V) where V: Into>` ## skip_hours ### Description Get, get mutable, or set the hours (0-23) to skip checking for updates. ### Methods - `skip_hours(&self) -> &[String]` - `skip_hours_mut(&mut self) -> &mut [String]` - `set_skip_hours(&mut self, skip_hours: V) where V: Into>` ## skip_days ### Description Get, get mutable, or set the days (Monday-Sunday) to skip checking for updates. ### Methods - `skip_days(&self) -> &[String]` - `skip_days_mut(&mut self) -> &mut [String]` - `set_skip_days(&mut self, skip_days: V) where V: Into>` ## items ### Description Access feed items. `into_items()` consumes the channel and returns items. ### Methods - `items(&self) -> &[Item]` - `items_mut(&mut self) -> &mut [Item]` - `into_items(self) -> Vec` - `set_items(&mut self, items: V) where V: Into>` ``` -------------------------------- ### Cloud Usage with Builder Pattern Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/cloud.md Demonstrates creating a Cloud object using the builder pattern, which provides a fluent API for setting fields. ```rust use rss::CloudBuilder; let cloud = CloudBuilder::default() .domain("http://rpc.example.com") .port("80") .path("/rpc") .register_procedure("pingMe") .protocol("xml-rpc") .build(); ``` -------------------------------- ### Manage Item Categories Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Provides methods to get, get mutable access to, or set the categories associated with an item. ```rust pub fn categories(&self) -> &[Category] pub fn categories_mut(&mut self) -> &mut [Category] pub fn set_categories(&mut self, categories: V) where V: Into> ``` -------------------------------- ### Aggregator Use Case with Source Tracking Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Demonstrates how to create an RSS channel and add items, with each item tracking its original source using the Source struct. ```rust use rss::{Channel, Item, Source}; let mut channel = Channel::default(); channel.set_title("Tech News Aggregator"); channel.set_link("https://aggregator.example.com"); channel.set_description("Curated tech articles from various sources"); // Create item with source tracking let mut item = Item::default(); item.set_title("New Language Feature Announced"); item.set_description("A new feature has been added to the language"); // Track original source item.set_source(Some(Source { url: "https://official-lang-blog.com/feed.xml".to_string(), title: Some("Official Language Blog".to_string()), })); channel.set_items(vec![item]); ``` -------------------------------- ### Default Constructor Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Provides a default Source instance with an empty URL and no title. ```APIDOC ## Default Constructor ```rust impl Default for Source { fn default() -> Source } ``` **Returns:** Source with empty URL and no title ``` -------------------------------- ### Category Creation Using Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/category.md Illustrates how to construct a `Category` object using the `CategoryBuilder`, which provides a fluent API for setting properties. ```rust use rss::CategoryBuilder; let cat = CategoryBuilder::default() .name("Technology") .domain("https://dmoz.org") .build(); ``` -------------------------------- ### Create Item using Builder Pattern Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/item.md Demonstrates creating an RSS Item using the builder pattern for setting various fields like title, link, description, publication date, and author. ```rust use rss::ItemBuilder; let item = ItemBuilder::default() .title("Breaking News: New Release") .link("https://example.com/news/item1") .description("A new version has been released with important features") .pub_date("Mon, 06 Jan 2024 12:00:00 GMT".to_string()) .author("editor@example.com") .build(); ``` -------------------------------- ### Guid Struct Definition Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/guid.md Defines the structure for a Globally Unique Identifier (GUID) in RSS. It includes a string value and a boolean indicating if it's a permalink. ```rust pub struct Guid { pub value: String, pub permalink: bool, } ``` -------------------------------- ### TextInput Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Demonstrates how to use the TextInputBuilder to construct a TextInput instance. ```APIDOC ## Using Builder ### Description Constructs a `TextInput` instance using a fluent builder pattern. This requires the `builders` feature. ### Usage ```rust use rss::TextInputBuilder; let text_input = TextInputBuilder::default() .title("Find Articles") .description("Search our article database") .name("search_term") .link("https://example.com/search.cgi") .build(); ``` ``` -------------------------------- ### Option Pattern for Optional Fields Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/overview.md Shows how to handle optional fields, which are represented as Option. Demonstrates checking for `Some` values and setting fields with `Some` or `None`. ```rust // Check and get if let Some(author) = item.author() { println!("Author: {}", author); } // Set with Option item.set_author(Some("John Doe".to_string())); item.set_author(None); // Set with Into item.set_author("Jane Doe"); // Auto-converts to Some(String) ``` -------------------------------- ### description Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Get the channel description. ```APIDOC ## description ### Description Get the channel description. ### Method `description` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```rust // Assuming 'channel' is a Channel instance let description = channel.description(); ``` ### Response #### Success Response - Returns the channel description as a string slice (`&str`). #### Response Example None provided. ``` -------------------------------- ### Using Source Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Constructs a Source instance using the builder pattern. This requires the 'builders' feature. ```rust use rss::SourceBuilder; let source = SourceBuilder::default() .url("https://news.example.com/feed") .title("Example News") .build(); ``` -------------------------------- ### title Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Get the channel title. ```APIDOC ## title ### Description Get the channel title. ### Method `title` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```rust // Assuming 'channel' is a Channel instance let title = channel.title(); ``` ### Response #### Success Response - Returns the channel title as a string slice (`&str`). #### Response Example None provided. ``` -------------------------------- ### Create and Write RSS Channel Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Demonstrates creating a basic RSS channel with items and writing it to a string or a file. Uses both direct field setting and the builder pattern. ```rust use rss::{Channel, Item, ChannelBuilder}; let mut channel = Channel::default(); channel.set_title("Tech News"); channel.set_link("https://example.com"); channel.set_description("Latest tech updates"); let mut item = Item::default(); item.set_title("Breaking: New Framework Released"); item.set_link("https://example.com/news/1"); item.set_description("A new web framework has been announced"); channel.set_items(vec![item]); // Using builder pattern let channel = ChannelBuilder::default() .title("Tech News") .link("https://example.com") .description("Latest updates") .build(); // Write as string let xml = channel.to_string(); println!("{}", xml); // Write to file let file = std::fs::File::create("feed.xml")?; channel.write_to(file)?; ``` -------------------------------- ### Rust RSS Channel Getters and Setters Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Provides methods to get, get mutable, or set categories, cloud information, image, text input, skip hours, skip days, and items for an RSS channel. ```rust pub fn categories(&self) -> &[Category] pub fn categories_mut(&mut self) -> &mut [Category] pub fn set_categories(&mut self, categories: V) where V: Into> ``` ```rust pub fn cloud(&self) -> Option<&Cloud> pub fn set_cloud(&mut self, cloud: V) where V: Into> ``` ```rust pub fn image(&self) -> Option<&Image> pub fn set_image(&mut self, image: V) where V: Into> ``` ```rust pub fn text_input(&self) -> Option<&TextInput> pub fn set_text_input(&mut self, text_input: V) where V: Into> ``` ```rust pub fn skip_hours(&self) -> &[String] pub fn skip_hours_mut(&mut self) -> &mut [String] pub fn set_skip_hours(&mut self, skip_hours: V) where V: Into> ``` ```rust pub fn skip_days(&self) -> &[String] pub fn skip_days_mut(&mut self) -> &mut [String] pub fn set_skip_days(&mut self, skip_days: V) where V: Into> ``` ```rust pub fn items(&self) -> &[Item] pub fn items_mut(&mut self) -> &mut [Item] pub fn into_items(self) -> Vec pub fn set_items(&mut self, items: V) where V: Into> ``` -------------------------------- ### TextInput Creation with Builder Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/textinput.md Demonstrates using the TextInputBuilder to construct a TextInput instance in a fluent manner. ```rust use rss::TextInputBuilder; let text_input = TextInputBuilder::default() .title("Find Articles") .description("Search our article database") .name("search_term") .link("https://example.com/search.cgi") .build(); ``` -------------------------------- ### Builder Pattern for Channel Creation Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/overview.md Demonstrates creating a Channel using the builder pattern, available when the `builders` feature is enabled. This allows for fluent construction of complex objects. ```rust use rss::ChannelBuilder; let channel = ChannelBuilder::default() .title("Feed Title") .link("https://example.com") .description("Feed description") .category(Category { name: "Tech".into(), domain: None }) .item(Item::default()) .build(); ``` -------------------------------- ### Basic Source Reference Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/source.md Creates and uses a Source instance to represent the origin of an RSS item. ```rust use rss::Source; let source = Source { url: "https://original-site.com/feed.xml".to_string(), title: Some("Original Blog".to_string()), }; assert_eq!(source.url(), "https://original-site.com/feed.xml"); assert_eq!(source.title(), Some("Original Blog")); ``` -------------------------------- ### Set iTunes Extension Fields Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/extensions.md Demonstrates how to set various iTunes-specific fields for a channel, such as author, image, explicit content rating, and summary. ```rust use rss::Channel; use rss::extension::itunes::ITunesChannelExtension; let mut channel = Channel::default(); channel.set_title("My Podcast"); let mut itunes = ITunesChannelExtension::default(); itunes.set_author(Some("John Host".to_string())); itunes.set_image(Some("https://example.com/podcast.jpg".to_string())); itunes.set_explicit(Some("clean".to_string())); itunes.set_summary(Some("A great podcast about tech".to_string())); channel.set_itunes_ext(Some(itunes)); ``` -------------------------------- ### copyright Source: https://github.com/rust-syndication/rss/blob/master/_autodocs/api-reference/channel.md Get the channel copyright notice. ```APIDOC ## copyright ### Description Get the channel copyright notice. ### Method `copyright` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```rust // Assuming 'channel' is a Channel instance let copyright = channel.copyright(); ``` ### Response #### Success Response - Returns the copyright notice as an `Option<&str>`. #### Response Example None provided. ```