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#[cfg(feature = "streaming")]
25pub mod subscribe_repos;
26
27#[derive(Debug, Clone, PartialEq, Eq, Hash)]
28pub enum HostStatus<'a> {
29    Active,
30    Idle,
31    Offline,
32    Throttled,
33    Banned,
34    Other(jacquard_common::CowStr<'a>),
35}
36
37impl<'a> HostStatus<'a> {
38    pub fn as_str(&self) -> &str {
39        match self {
40            Self::Active => "active",
41            Self::Idle => "idle",
42            Self::Offline => "offline",
43            Self::Throttled => "throttled",
44            Self::Banned => "banned",
45            Self::Other(s) => s.as_ref(),
46        }
47    }
48}
49
50impl<'a> From<&'a str> for HostStatus<'a> {
51    fn from(s: &'a str) -> Self {
52        match s {
53            "active" => Self::Active,
54            "idle" => Self::Idle,
55            "offline" => Self::Offline,
56            "throttled" => Self::Throttled,
57            "banned" => Self::Banned,
58            _ => Self::Other(jacquard_common::CowStr::from(s)),
59        }
60    }
61}
62
63impl<'a> From<String> for HostStatus<'a> {
64    fn from(s: String) -> Self {
65        match s.as_str() {
66            "active" => Self::Active,
67            "idle" => Self::Idle,
68            "offline" => Self::Offline,
69            "throttled" => Self::Throttled,
70            "banned" => Self::Banned,
71            _ => Self::Other(jacquard_common::CowStr::from(s)),
72        }
73    }
74}
75
76impl<'a> AsRef<str> for HostStatus<'a> {
77    fn as_ref(&self) -> &str {
78        self.as_str()
79    }
80}
81
82impl<'a> serde::Serialize for HostStatus<'a> {
83    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
84    where
85        S: serde::Serializer,
86    {
87        serializer.serialize_str(self.as_str())
88    }
89}
90
91impl<'de, 'a> serde::Deserialize<'de> for HostStatus<'a>
92where
93    'de: 'a,
94{
95    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
96    where
97        D: serde::Deserializer<'de>,
98    {
99        let s = <&'de str>::deserialize(deserializer)?;
100        Ok(Self::from(s))
101    }
102}
103
104impl jacquard_common::IntoStatic for HostStatus<'_> {
105    type Output = HostStatus<'static>;
106    fn into_static(self) -> Self::Output {
107        match self {
108            HostStatus::Active => HostStatus::Active,
109            HostStatus::Idle => HostStatus::Idle,
110            HostStatus::Offline => HostStatus::Offline,
111            HostStatus::Throttled => HostStatus::Throttled,
112            HostStatus::Banned => HostStatus::Banned,
113            HostStatus::Other(v) => HostStatus::Other(v.into_static()),
114        }
115    }
116}