Skip to main content

synd_client/payload/
timeline.rs

1use serde::Deserialize;
2use synd_feed::{
3    entry::EntryId,
4    types::{Category, FeedUrl, Requirement, Time},
5};
6
7use super::PageInfo;
8
9/// Entry as it appears on one timeline: display position + content.
10#[derive(Debug, Clone, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct TimelineEntry {
13    pub order_time: Time,
14    pub entry: Entry,
15}
16
17#[derive(Debug, Clone, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct TimelineEntryConnection {
20    pub nodes: Vec<TimelineEntry>,
21    pub page_info: PageInfo,
22    /// Change seq this page reflects. The client syncs changes from here
23    pub seq: i64,
24}
25
26/// Page of timeline changes for incremental sync, ordered by seq.
27#[derive(Debug, Clone, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct TimelineChangesPayload {
30    pub changes: Vec<TimelineChange>,
31    /// Seq the client remembers after applying this page
32    pub seq: i64,
33    pub has_more: bool,
34}
35
36/// One timeline change, applied in seq order.
37#[derive(Debug, Clone, Deserialize)]
38#[serde(tag = "__typename")]
39pub enum TimelineChange {
40    /// Insert or overwrite the entry at its `(order_time, entry.id)` position
41    #[serde(rename = "TimelineChangeUpsert", rename_all = "camelCase")]
42    Upsert { timeline_entry: Box<TimelineEntry> },
43    /// Remove the entry identified by `entry_id`
44    #[serde(rename = "TimelineChangeRemove", rename_all = "camelCase")]
45    Remove { entry_id: EntryId },
46}
47
48#[derive(Debug, Clone, Deserialize)]
49#[serde(rename_all = "camelCase")]
50pub struct Entry {
51    pub id: EntryId,
52    pub title: Option<String>,
53    pub published: Option<Time>,
54    pub updated: Option<Time>,
55    pub website_url: Option<String>,
56    pub summary: Option<String>,
57    pub feed: FeedMeta,
58}
59
60#[derive(Debug, Clone, Deserialize)]
61pub struct FeedMeta {
62    pub title: Option<String>,
63    pub url: FeedUrl,
64    #[serde(default, with = "super::requirement")]
65    pub requirement: Option<Requirement>,
66    pub category: Option<Category<'static>>,
67}