Skip to main content

spoolframe_protocol/
plex.rs

1//! The session user's Plex account link, as clients may read it.
2//! Linking and unlinking are the web UI's (`<web_url>/profile`): a client
3//! only shows the state, and never sees the account's token.
4
5use serde::{Deserialize, Serialize};
6
7/// A linked Plex account: the user's watch state syncs with it.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
10pub struct PlexLink {
11    /// The Plex account's username and email, as plex.tv said when it was
12    /// linked; both `None` for a link the server's config file makes.
13    pub username: Option<String>,
14    pub email: Option<String>,
15    /// Linked by the server's config file, as the Plex servers' owner:
16    /// only that file can unlink it, not the web UI.
17    pub by_config: bool,
18    /// When it was linked, Unix seconds; `None` for the config's.
19    pub linked_at: Option<i64>,
20    /// The user's last sync run since the server started, if any.
21    pub last_sync: Option<PlexSyncSummary>,
22    /// A sync run of theirs is going on now.
23    pub syncing: bool,
24}
25
26/// What one sync run did.
27#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
28#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
29pub struct PlexSyncSummary {
30    /// When it ended, Unix seconds.
31    pub at: i64,
32    /// The libraries synced.
33    pub libraries: u32,
34    /// Items whose state was taken from Plex, sent to Plex, left as they
35    /// were, and that failed.
36    pub pulled: u32,
37    pub pushed: u32,
38    pub skipped: u32,
39    pub failed: u32,
40}