Skip to main content

spoolframe_protocol/federation/
subtitles.rs

1//! Subtitle search on a paired server's item (P8-07): the server the user
2//! is at home on (SB) passes `SearchSubtitles`, `DownloadSubtitle` and
3//! `RemoveSubtitleDownload` of a `fed:` item to the server whose item it
4//! is (SA), which plans the play and burns subtitles in, so the file must
5//! be there.
6//!
7//! SA searches with its own sites and ranking, ordered by the user's own
8//! SDH and forced choices on SB, and keeps what it downloads as its own,
9//! for everyone. Every user of SB's together gets one daily allowance on
10//! SA (`subtitles { daily_limit_per_peer }`), counted under the pair and
11//! never under SB's users, whom SA never names; SB holds each of its users
12//! to its own per-user limit first.
13//!
14//! Each ask arrives on the pair's connection, which proves who sends it,
15//! as an assertion does (P8-03): the user is SB's local account, by its
16//! stable id.
17
18use serde::{Deserialize, Serialize};
19use spoolframe_types::SubtitlePreferences;
20
21/// `SearchSubtitles` of SA's item `item` for SB's `user`: `SubtitleResults`,
22/// or `Failed`.
23#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
24pub struct SubtitleSearchAsk {
25    /// The user's stable id on SB, as an assertion names them.
26    pub user: String,
27    /// Their subtitle choices on SB: what the results are ordered by.
28    #[serde(default)]
29    pub subtitles: SubtitlePreferences,
30    /// The item, by SA's own id.
31    pub item: String,
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub language: Option<String>,
34}
35
36/// `DownloadSubtitle` of result `result` of a search for SA's `item`, for
37/// SB's `user`: `SubtitleDownloaded`, or `Failed`.
38#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
39pub struct SubtitleDownloadAsk {
40    pub user: String,
41    pub item: String,
42    pub result: String,
43}
44
45/// `RemoveSubtitleDownload` of download `download` of SA's `item`, for SB's
46/// `user`: `Done`, or `Failed`.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48pub struct SubtitleRemovalAsk {
49    pub user: String,
50    pub item: String,
51    pub download: String,
52}