Struct opml::OPML [−][src]
Expand description
The top-level OPML element.
Fields
version: String
The version attribute from the element, valid values are 1.0
, 1.1
and 2.0
.
head: Option<Head>
The Head child element. Contains the metadata of the OPML document.
body: Body
Implementations
👎 Deprecated since 1.1.0: use from_str instead
use from_str instead
Parses an OPML document.
Example
use opml::{OPML, Outline}; let xml = r#"<opml version="2.0"><head/><body><outline text="Outline"/></body></opml>"#; let parsed = OPML::new(xml).unwrap(); let mut expected = OPML::default(); expected.body.outlines.push(Outline { text: "Outline".to_string(), ..Outline::default() }); assert_eq!(parsed, expected);
Parses an OPML document.
Example
use opml::{OPML, Outline}; let xml = r#"<opml version="2.0"><head/><body><outline text="Outline"/></body></opml>"#; let parsed = OPML::from_str(xml).unwrap(); let mut expected = OPML::default(); expected.body.outlines.push(Outline { text: "Outline".to_string(), ..Outline::default() }); assert_eq!(parsed, expected);
Parses an OPML document from a reader.
Example
use opml::{OPML, Outline}; use std::fs::File; let mut file = File::open("file.opml").unwrap(); let parsed = OPML::from_reader(&mut file).unwrap();
Helper function to add an Outline element with text
and xml_url
attributes to the Body. Useful for creating feed lists quickly. This function also exists on the Outline struct to create grouped lists easily.
Example
use opml::{OPML, Outline}; let mut opml = OPML::default(); opml.add_feed("Feed Name", "https://example.com/"); let added_feed = opml.body.outlines.first().unwrap(); let expected_feed = &Outline { text: "Feed Name".to_string(), xml_url: Some("https://example.com/".to_string()), ..Outline::default() }; assert_eq!(added_feed, expected_feed);
👎 Deprecated: Use to_string instead
Use to_string instead
Converts the struct to an XML document.
Example
use opml::OPML; let opml = OPML::default(); let xml = opml.to_xml().unwrap(); let expected = r#"<opml version="2.0"><head/><body/></opml>"#; assert_eq!(xml, expected);
Converts the struct to an XML document.
Example
use opml::OPML; let opml = OPML::default(); let xml = opml.to_string().unwrap(); let expected = r#"<opml version="2.0"><head/><body/></opml>"#; assert_eq!(xml, expected);
Converts the struct to an XML document and writes it using the writer.
Example
use opml::OPML; use std::fs::File; let opml = OPML::default(); let mut file = File::create("file.opml").unwrap(); let xml = opml.to_writer(&mut file).unwrap();
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for OPML
impl UnwindSafe for OPML
Blanket Implementations
Mutably borrows from an owned value. Read more