jacquard_api/com_atproto/sync/
get_host_status.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::com_atproto::sync::HostStatus;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetHostStatus<'a> {
21 #[serde(borrow)]
22 pub hostname: CowStr<'a>,
23}
24
25
26#[lexicon]
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
28#[serde(rename_all = "camelCase")]
29pub struct GetHostStatusOutput<'a> {
30 #[serde(skip_serializing_if = "Option::is_none")]
32 pub account_count: Option<i64>,
33 #[serde(borrow)]
34 pub hostname: CowStr<'a>,
35 #[serde(skip_serializing_if = "Option::is_none")]
37 pub seq: Option<i64>,
38 #[serde(skip_serializing_if = "Option::is_none")]
39 #[serde(borrow)]
40 pub status: Option<HostStatus<'a>>,
41}
42
43
44#[open_union]
45#[derive(
46 Serialize,
47 Deserialize,
48 Debug,
49 Clone,
50 PartialEq,
51 Eq,
52 thiserror::Error,
53 miette::Diagnostic,
54 IntoStatic
55)]
56
57#[serde(tag = "error", content = "message")]
58#[serde(bound(deserialize = "'de: 'a"))]
59pub enum GetHostStatusError<'a> {
60 #[serde(rename = "HostNotFound")]
61 HostNotFound(Option<CowStr<'a>>),
62}
63
64impl core::fmt::Display for GetHostStatusError<'_> {
65 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
66 match self {
67 Self::HostNotFound(msg) => {
68 write!(f, "HostNotFound")?;
69 if let Some(msg) = msg {
70 write!(f, ": {}", msg)?;
71 }
72 Ok(())
73 }
74 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
75 }
76 }
77}
78
79pub struct GetHostStatusResponse;
81impl jacquard_common::xrpc::XrpcResp for GetHostStatusResponse {
82 const NSID: &'static str = "com.atproto.sync.getHostStatus";
83 const ENCODING: &'static str = "application/json";
84 type Output<'de> = GetHostStatusOutput<'de>;
85 type Err<'de> = GetHostStatusError<'de>;
86}
87
88impl<'a> jacquard_common::xrpc::XrpcRequest for GetHostStatus<'a> {
89 const NSID: &'static str = "com.atproto.sync.getHostStatus";
90 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
91 type Response = GetHostStatusResponse;
92}
93
94pub struct GetHostStatusRequest;
96impl jacquard_common::xrpc::XrpcEndpoint for GetHostStatusRequest {
97 const PATH: &'static str = "/xrpc/com.atproto.sync.getHostStatus";
98 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
99 type Request<'de> = GetHostStatus<'de>;
100 type Response = GetHostStatusResponse;
101}
102
103pub mod get_host_status_state {
104
105 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
106 #[allow(unused)]
107 use ::core::marker::PhantomData;
108 mod sealed {
109 pub trait Sealed {}
110 }
111 pub trait State: sealed::Sealed {
113 type Hostname;
114 }
115 pub struct Empty(());
117 impl sealed::Sealed for Empty {}
118 impl State for Empty {
119 type Hostname = Unset;
120 }
121 pub struct SetHostname<S: State = Empty>(PhantomData<fn() -> S>);
123 impl<S: State> sealed::Sealed for SetHostname<S> {}
124 impl<S: State> State for SetHostname<S> {
125 type Hostname = Set<members::hostname>;
126 }
127 #[allow(non_camel_case_types)]
129 pub mod members {
130 pub struct hostname(());
132 }
133}
134
135pub struct GetHostStatusBuilder<'a, S: get_host_status_state::State> {
137 _state: PhantomData<fn() -> S>,
138 _fields: (Option<CowStr<'a>>,),
139 _lifetime: PhantomData<&'a ()>,
140}
141
142impl<'a> GetHostStatus<'a> {
143 pub fn new() -> GetHostStatusBuilder<'a, get_host_status_state::Empty> {
145 GetHostStatusBuilder::new()
146 }
147}
148
149impl<'a> GetHostStatusBuilder<'a, get_host_status_state::Empty> {
150 pub fn new() -> Self {
152 GetHostStatusBuilder {
153 _state: PhantomData,
154 _fields: (None,),
155 _lifetime: PhantomData,
156 }
157 }
158}
159
160impl<'a, S> GetHostStatusBuilder<'a, S>
161where
162 S: get_host_status_state::State,
163 S::Hostname: get_host_status_state::IsUnset,
164{
165 pub fn hostname(
167 mut self,
168 value: impl Into<CowStr<'a>>,
169 ) -> GetHostStatusBuilder<'a, get_host_status_state::SetHostname<S>> {
170 self._fields.0 = Option::Some(value.into());
171 GetHostStatusBuilder {
172 _state: PhantomData,
173 _fields: self._fields,
174 _lifetime: PhantomData,
175 }
176 }
177}
178
179impl<'a, S> GetHostStatusBuilder<'a, S>
180where
181 S: get_host_status_state::State,
182 S::Hostname: get_host_status_state::IsSet,
183{
184 pub fn build(self) -> GetHostStatus<'a> {
186 GetHostStatus {
187 hostname: self._fields.0.unwrap(),
188 }
189 }
190}