Skip to main content

jacquard_api/com_atproto/sync/
get_host_status.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.getHostStatus
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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    ///Number of accounts on the server which are associated with the upstream host. Note that the upstream may actually have more accounts.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub account_count: Option<i64>,
33    #[serde(borrow)]
34    pub hostname: CowStr<'a>,
35    ///Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor).
36    #[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
79/// Response type for com.atproto.sync.getHostStatus
80pub 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
94/// Endpoint type for com.atproto.sync.getHostStatus
95pub 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    /// State trait tracking which required fields have been set
112    pub trait State: sealed::Sealed {
113        type Hostname;
114    }
115    /// Empty state - all required fields are unset
116    pub struct Empty(());
117    impl sealed::Sealed for Empty {}
118    impl State for Empty {
119        type Hostname = Unset;
120    }
121    ///State transition - sets the `hostname` field to Set
122    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    /// Marker types for field names
128    #[allow(non_camel_case_types)]
129    pub mod members {
130        ///Marker type for the `hostname` field
131        pub struct hostname(());
132    }
133}
134
135/// Builder for constructing an instance of this type
136pub 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    /// Create a new builder for this type
144    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    /// Create a new builder with all fields unset
151    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    /// Set the `hostname` field (required)
166    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    /// Build the final struct
185    pub fn build(self) -> GetHostStatus<'a> {
186        GetHostStatus {
187            hostname: self._fields.0.unwrap(),
188        }
189    }
190}