parse_sap_atom_feed/atom/feed/
mod.rs

1pub mod author;
2pub mod entry;
3
4use super::link::AtomLink;
5use crate::xml::{default_xml_namespace_atom, default_xml_namespace_d, default_xml_namespace_m};
6use author::Author;
7use entry::Entry;
8
9use serde::{de::DeserializeOwned, Deserialize, Serialize};
10
11// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12/// Represents an Atom `<feed>`
13///
14/// # Child Nodes
15/// `1:1 author`<br>
16/// `1:1 link`<br>
17/// `0:n entry`
18///
19/// ***WARNING:***<br>`quick-xml` strips the namespace from both XML tag and attribute names!
20#[derive(Debug, Serialize, Deserialize)]
21pub struct Feed<T> {
22    #[serde(rename = "@xmlns", default = "default_xml_namespace_atom")]
23    pub namespace: Option<String>,
24
25    // Appears in the XML as the `feed` attribute `xmlns:m`
26    #[serde(rename = "@m", default = "default_xml_namespace_m")]
27    pub namespace_m: String,
28
29    // Appears in the XML as the `feed` attribute `xmlns:d`
30    #[serde(rename = "@d", default = "default_xml_namespace_d")]
31    pub namespace_d: String,
32
33    // Appears in the XML as the `feed` attribute `xmlns:base`
34    #[serde(rename = "@base")]
35    pub xml_base: Option<String>,
36
37    pub id: String,
38    pub title: String,
39    pub updated: String,
40    pub author: Author,
41
42    #[serde(rename = "link")]
43    pub links: Vec<AtomLink>,
44
45    #[serde(rename = "entry")]
46    pub entries: Option<Vec<Entry<T>>>,
47}
48
49impl<T> std::str::FromStr for Feed<T>
50where
51    T: DeserializeOwned,
52{
53    type Err = quick_xml::DeError;
54
55    fn from_str(s: &str) -> Result<Self, Self::Err> {
56        quick_xml::de::from_str(s)
57    }
58}