jacquard_api/com_atproto/sync/
get_record.rs

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