Skip to main content

jacquard_api/com_atproto/
sync.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod get_blob;
9pub mod get_blocks;
10pub mod get_checkout;
11pub mod get_head;
12pub mod get_host_status;
13pub mod get_latest_commit;
14pub mod get_record;
15pub mod get_repo;
16pub mod get_repo_status;
17pub mod list_blobs;
18pub mod list_hosts;
19pub mod list_repos;
20pub mod list_repos_by_collection;
21pub mod notify_of_update;
22pub mod request_crawl;
23
24
25#[cfg(feature = "streaming")]
26pub mod subscribe_repos;
27
28use jacquard_common::CowStr;
29
30#[derive(Debug, Clone, PartialEq, Eq, Hash)]
31pub enum HostStatus<'a> {
32    Active,
33    Idle,
34    Offline,
35    Throttled,
36    Banned,
37    Other(CowStr<'a>),
38}
39
40impl<'a> HostStatus<'a> {
41    pub fn as_str(&self) -> &str {
42        match self {
43            Self::Active => "active",
44            Self::Idle => "idle",
45            Self::Offline => "offline",
46            Self::Throttled => "throttled",
47            Self::Banned => "banned",
48            Self::Other(s) => s.as_ref(),
49        }
50    }
51}
52
53impl<'a> From<&'a str> for HostStatus<'a> {
54    fn from(s: &'a str) -> Self {
55        match s {
56            "active" => Self::Active,
57            "idle" => Self::Idle,
58            "offline" => Self::Offline,
59            "throttled" => Self::Throttled,
60            "banned" => Self::Banned,
61            _ => Self::Other(CowStr::from(s)),
62        }
63    }
64}
65
66impl<'a> From<String> for HostStatus<'a> {
67    fn from(s: String) -> Self {
68        match s.as_str() {
69            "active" => Self::Active,
70            "idle" => Self::Idle,
71            "offline" => Self::Offline,
72            "throttled" => Self::Throttled,
73            "banned" => Self::Banned,
74            _ => Self::Other(CowStr::from(s)),
75        }
76    }
77}
78
79impl<'a> AsRef<str> for HostStatus<'a> {
80    fn as_ref(&self) -> &str {
81        self.as_str()
82    }
83}
84
85impl<'a> core::fmt::Display for HostStatus<'a> {
86    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
87        write!(f, "{}", self.as_str())
88    }
89}
90
91impl<'a> serde::Serialize for HostStatus<'a> {
92    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
93    where
94        S: serde::Serializer,
95    {
96        serializer.serialize_str(self.as_str())
97    }
98}
99
100impl<'de, 'a> serde::Deserialize<'de> for HostStatus<'a>
101where
102    'de: 'a,
103{
104    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
105    where
106        D: serde::Deserializer<'de>,
107    {
108        let s = <&'de str>::deserialize(deserializer)?;
109        Ok(Self::from(s))
110    }
111}
112
113impl jacquard_common::IntoStatic for HostStatus<'_> {
114    type Output = HostStatus<'static>;
115    fn into_static(self) -> Self::Output {
116        match self {
117            HostStatus::Active => HostStatus::Active,
118            HostStatus::Idle => HostStatus::Idle,
119            HostStatus::Offline => HostStatus::Offline,
120            HostStatus::Throttled => HostStatus::Throttled,
121            HostStatus::Banned => HostStatus::Banned,
122            HostStatus::Other(v) => HostStatus::Other(v.into_static()),
123        }
124    }
125}