parse_sap_atom_feed/atom/feed/entry/mod.rs
1use serde::{de::DeserializeOwned, Deserialize, Serialize};
2
3use crate::atom::feed::{entry::content::Content, AtomLink};
4use entry_category::EntryCategory;
5
6pub mod category;
7pub mod content;
8pub mod entry_category;
9
10// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11/// Represents an Atom `<entry>` of type `<T>` where `<T>` is the entity type of this particular entity set
12///
13/// # Child Nodes
14/// `1:1 id`<br>
15/// `1:1 title`<br>
16/// `1:1 updated`<br>
17/// `1:1 category`<br>
18/// `1:n link`<br>
19/// `1:1 content`<br>
20#[derive(Debug, Serialize, Deserialize)]
21pub struct Entry<T> {
22 // Appears in the XML as the `entry` attribute `m:etag`
23 #[serde(rename = "@etag")]
24 pub etag: Option<String>,
25
26 pub id: String,
27 pub title: String,
28 pub updated: String,
29 pub category: EntryCategory,
30
31 #[serde(rename = "link")]
32 pub links: Vec<AtomLink>,
33
34 pub content: Content<T>,
35
36 // This `properties` field will only be populated if the `src` attribute of above `<content>` element exists.
37 // If the `src` attribute is missing, then this `properties` field will be `None` and there will be a `properties`
38 // child within `<content>`
39 pub properties: Option<T>,
40}
41
42impl<T> std::str::FromStr for Entry<T>
43where
44 T: DeserializeOwned,
45{
46 type Err = quick_xml::DeError;
47
48 fn from_str(s: &str) -> Result<Self, Self::Err> {
49 quick_xml::de::from_str(s)
50 }
51}
52
53// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54#[cfg(test)]
55pub mod unit_tests;