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