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#[derive(
9    serde::Serialize,
10    serde::Deserialize,
11    Debug,
12    Clone,
13    PartialEq,
14    Eq,
15    bon::Builder
16)]
17#[builder(start_fn = new)]
18#[serde(rename_all = "camelCase")]
19pub struct GetHostStatus<'a> {
20    #[serde(borrow)]
21    #[builder(into)]
22    pub hostname: jacquard_common::CowStr<'a>,
23}
24
25impl jacquard_common::IntoStatic for GetHostStatus<'_> {
26    type Output = GetHostStatus<'static>;
27    fn into_static(self) -> Self::Output {
28        GetHostStatus {
29            hostname: self.hostname.into_static(),
30        }
31    }
32}
33
34#[jacquard_derive::lexicon]
35#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
36#[serde(rename_all = "camelCase")]
37pub struct GetHostStatusOutput<'a> {
38    ///Number of accounts on the server which are associated with the upstream host. Note that the upstream may actually have more accounts.
39    #[serde(skip_serializing_if = "std::option::Option::is_none")]
40    pub account_count: std::option::Option<i64>,
41    #[serde(borrow)]
42    pub hostname: jacquard_common::CowStr<'a>,
43    ///Recent repo stream event sequence number. May be delayed from actual stream processing (eg, persisted cursor not in-memory cursor).
44    #[serde(skip_serializing_if = "std::option::Option::is_none")]
45    pub seq: std::option::Option<i64>,
46    #[serde(skip_serializing_if = "std::option::Option::is_none")]
47    #[serde(borrow)]
48    pub status: std::option::Option<crate::com_atproto::sync::HostStatus<'a>>,
49}
50
51impl jacquard_common::IntoStatic for GetHostStatusOutput<'_> {
52    type Output = GetHostStatusOutput<'static>;
53    fn into_static(self) -> Self::Output {
54        GetHostStatusOutput {
55            account_count: self.account_count.into_static(),
56            hostname: self.hostname.into_static(),
57            seq: self.seq.into_static(),
58            status: self.status.into_static(),
59            extra_data: self.extra_data.into_static(),
60        }
61    }
62}
63
64#[jacquard_derive::open_union]
65#[derive(
66    serde::Serialize,
67    serde::Deserialize,
68    Debug,
69    Clone,
70    PartialEq,
71    Eq,
72    thiserror::Error,
73    miette::Diagnostic
74)]
75#[serde(tag = "error", content = "message")]
76#[serde(bound(deserialize = "'de: 'a"))]
77pub enum GetHostStatusError<'a> {
78    #[serde(rename = "HostNotFound")]
79    HostNotFound(std::option::Option<String>),
80}
81
82impl std::fmt::Display for GetHostStatusError<'_> {
83    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84        match self {
85            Self::HostNotFound(msg) => {
86                write!(f, "HostNotFound")?;
87                if let Some(msg) = msg {
88                    write!(f, ": {}", msg)?;
89                }
90                Ok(())
91            }
92            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
93        }
94    }
95}
96
97impl jacquard_common::IntoStatic for GetHostStatusError<'_> {
98    type Output = GetHostStatusError<'static>;
99    fn into_static(self) -> Self::Output {
100        match self {
101            GetHostStatusError::HostNotFound(v) => {
102                GetHostStatusError::HostNotFound(v.into_static())
103            }
104            GetHostStatusError::Unknown(v) => {
105                GetHostStatusError::Unknown(v.into_static())
106            }
107        }
108    }
109}
110
111impl jacquard_common::types::xrpc::XrpcRequest for GetHostStatus<'_> {
112    const NSID: &'static str = "com.atproto.sync.getHostStatus";
113    const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query;
114    const OUTPUT_ENCODING: &'static str = "application/json";
115    type Output<'de> = GetHostStatusOutput<'de>;
116    type Err<'de> = GetHostStatusError<'de>;
117}