1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use serde::Deserialize;

#[derive(Clone, Debug, Deserialize)]
pub struct Summary {
    pub content: String,
    pub direction: Option<String>,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Alternate {
    pub href: String,
}

#[derive(Clone, Debug, Deserialize)]
pub struct Own {
    pub href: String,
}

#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Origin {
    pub stream_id: String,
    pub title: String,
    pub html_url: Option<String>,
}

#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Item {
    pub origin: Origin,
    pub updated: Option<i64>,
    pub id: String,
    pub categories: Vec<String>,
    pub author: Option<String>,
    pub alternate: Vec<Alternate>,
    pub timestamp_usec: String,
    pub crawl_time_msec: String,
    pub published: i64,
    pub title: Option<String>,
    #[serde(alias = "summary")]
    pub content: Option<Summary>,
}

#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Stream {
    pub direction: Option<String>,
    pub id: String,
    pub title: Option<String>,
    pub description: Option<String>,
    // r#self (raw identifier) could not be used, therefore i gets renamed to own
    #[serde(rename = "self")]
    pub own: Option<Own>,
    pub updated: i64,
    pub updated_usec: Option<String>,
    pub items: Vec<Item>,
    pub author: Option<String>,
    pub continuation: Option<String>,
}

impl Summary {
    pub fn decompose(self) -> (String, Option<String>) {
        (self.content, self.direction)
    }
}

impl Alternate {
    pub fn decompose(self) -> String {
        self.href
    }
}

impl Origin {
    pub fn decompose(self) -> (String, String, Option<String>) {
        (self.stream_id, self.title, self.html_url)
    }
}

impl Item {
    #[allow(clippy::type_complexity)]
    pub fn decompose(
        self,
    ) -> (
        Origin,
        Option<i64>,
        String,
        Vec<String>,
        Option<String>,
        Vec<Alternate>,
        String,
        String,
        i64,
        Option<String>,
        Option<Summary>,
    ) {
        (
            self.origin,
            self.updated,
            self.id,
            self.categories,
            self.author,
            self.alternate,
            self.timestamp_usec,
            self.crawl_time_msec,
            self.published,
            self.title,
            self.content,
        )
    }
}

impl Stream {
    #[allow(clippy::type_complexity)]
    pub fn decompose(
        self,
    ) -> (
        Option<String>,
        String,
        Option<String>,
        Option<String>,
        Option<Own>,
        i64,
        Option<String>,
        Vec<Item>,
        Option<String>,
        Option<String>,
    ) {
        (
            self.direction,
            self.id,
            self.title,
            self.description,
            self.own,
            self.updated,
            self.updated_usec,
            self.items,
            self.author,
            self.continuation,
        )
    }
}