Struct opml::OPML [−][src]
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
impl OPML
[src]
pub fn new(xml: &str) -> Result<Self, Error>
[src]
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);
pub fn add_feed(&mut self, text: &str, url: &str) -> &mut Self
[src]
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);
pub fn to_xml(&self) -> Result<String, Error>
[src]
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);
Trait Implementations
impl Clone for OPML
[src]
impl Debug for OPML
[src]
impl Default for OPML
[src]
impl<'de> Deserialize<'de> for OPML
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<OPML> for OPML
[src]
impl Serialize for OPML
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for OPML
[src]
impl<'__input> XmlRead<'__input> for OPML
[src]
fn from_reader(reader: &mut XmlReader<'__input>) -> XmlResult<Self>
[src]
pub fn from_str(text: &'a str) -> Result<Self, XmlError>
[src]
impl XmlWrite for OPML
[src]
Auto Trait Implementations
impl RefUnwindSafe for OPML
impl Send for OPML
impl Sync for OPML
impl Unpin for OPML
impl UnwindSafe for OPML
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> XmlReadOwned for T where
T: for<'s> XmlRead<'s>,
[src]
T: for<'s> XmlRead<'s>,