jacquard_api/com_atproto/sync/
get_latest_commit.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.getLatestCommit
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 GetLatestCommit<'a> {
20    #[serde(borrow)]
21    pub did: jacquard_common::types::string::Did<'a>,
22}
23
24impl jacquard_common::IntoStatic for GetLatestCommit<'_> {
25    type Output = GetLatestCommit<'static>;
26    fn into_static(self) -> Self::Output {
27        GetLatestCommit {
28            did: self.did.into_static(),
29        }
30    }
31}
32
33#[jacquard_derive::lexicon]
34#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
35#[serde(rename_all = "camelCase")]
36pub struct GetLatestCommitOutput<'a> {
37    #[serde(borrow)]
38    pub cid: jacquard_common::types::string::Cid<'a>,
39    pub rev: jacquard_common::types::string::Tid,
40}
41
42impl jacquard_common::IntoStatic for GetLatestCommitOutput<'_> {
43    type Output = GetLatestCommitOutput<'static>;
44    fn into_static(self) -> Self::Output {
45        GetLatestCommitOutput {
46            cid: self.cid.into_static(),
47            rev: self.rev.into_static(),
48            extra_data: self.extra_data.into_static(),
49        }
50    }
51}
52
53#[jacquard_derive::open_union]
54#[derive(
55    serde::Serialize,
56    serde::Deserialize,
57    Debug,
58    Clone,
59    PartialEq,
60    Eq,
61    thiserror::Error,
62    miette::Diagnostic
63)]
64#[serde(tag = "error", content = "message")]
65#[serde(bound(deserialize = "'de: 'a"))]
66pub enum GetLatestCommitError<'a> {
67    #[serde(rename = "RepoNotFound")]
68    RepoNotFound(std::option::Option<String>),
69    #[serde(rename = "RepoTakendown")]
70    RepoTakendown(std::option::Option<String>),
71    #[serde(rename = "RepoSuspended")]
72    RepoSuspended(std::option::Option<String>),
73    #[serde(rename = "RepoDeactivated")]
74    RepoDeactivated(std::option::Option<String>),
75}
76
77impl std::fmt::Display for GetLatestCommitError<'_> {
78    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
79        match self {
80            Self::RepoNotFound(msg) => {
81                write!(f, "RepoNotFound")?;
82                if let Some(msg) = msg {
83                    write!(f, ": {}", msg)?;
84                }
85                Ok(())
86            }
87            Self::RepoTakendown(msg) => {
88                write!(f, "RepoTakendown")?;
89                if let Some(msg) = msg {
90                    write!(f, ": {}", msg)?;
91                }
92                Ok(())
93            }
94            Self::RepoSuspended(msg) => {
95                write!(f, "RepoSuspended")?;
96                if let Some(msg) = msg {
97                    write!(f, ": {}", msg)?;
98                }
99                Ok(())
100            }
101            Self::RepoDeactivated(msg) => {
102                write!(f, "RepoDeactivated")?;
103                if let Some(msg) = msg {
104                    write!(f, ": {}", msg)?;
105                }
106                Ok(())
107            }
108            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
109        }
110    }
111}
112
113impl jacquard_common::IntoStatic for GetLatestCommitError<'_> {
114    type Output = GetLatestCommitError<'static>;
115    fn into_static(self) -> Self::Output {
116        match self {
117            GetLatestCommitError::RepoNotFound(v) => {
118                GetLatestCommitError::RepoNotFound(v.into_static())
119            }
120            GetLatestCommitError::RepoTakendown(v) => {
121                GetLatestCommitError::RepoTakendown(v.into_static())
122            }
123            GetLatestCommitError::RepoSuspended(v) => {
124                GetLatestCommitError::RepoSuspended(v.into_static())
125            }
126            GetLatestCommitError::RepoDeactivated(v) => {
127                GetLatestCommitError::RepoDeactivated(v.into_static())
128            }
129            GetLatestCommitError::Unknown(v) => {
130                GetLatestCommitError::Unknown(v.into_static())
131            }
132        }
133    }
134}
135
136impl jacquard_common::types::xrpc::XrpcRequest for GetLatestCommit<'_> {
137    const NSID: &'static str = "com.atproto.sync.getLatestCommit";
138    const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query;
139    const OUTPUT_ENCODING: &'static str = "application/json";
140    type Output<'de> = GetLatestCommitOutput<'de>;
141    type Err<'de> = GetLatestCommitError<'de>;
142}