atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.lexicon.resolveLexicon
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 jacquard_derive::IntoStatic
16)]
17#[serde(rename_all = "camelCase")]
18pub struct ResolveLexicon<'a> {
19 #[serde(borrow)]
20 pub nsid: jacquard_common::types::string::Nsid<'a>,
21}
22
23pub mod resolve_lexicon_state {
24
25 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
26 #[allow(unused)]
27 use ::core::marker::PhantomData;
28 mod sealed {
29 pub trait Sealed {}
30 }
31 /// State trait tracking which required fields have been set
32 pub trait State: sealed::Sealed {
33 type Nsid;
34 }
35 /// Empty state - all required fields are unset
36 pub struct Empty(());
37 impl sealed::Sealed for Empty {}
38 impl State for Empty {
39 type Nsid = Unset;
40 }
41 ///State transition - sets the `nsid` field to Set
42 pub struct SetNsid<S: State = Empty>(PhantomData<fn() -> S>);
43 impl<S: State> sealed::Sealed for SetNsid<S> {}
44 impl<S: State> State for SetNsid<S> {
45 type Nsid = Set<members::nsid>;
46 }
47 /// Marker types for field names
48 #[allow(non_camel_case_types)]
49 pub mod members {
50 ///Marker type for the `nsid` field
51 pub struct nsid(());
52 }
53}
54
55/// Builder for constructing an instance of this type
56pub struct ResolveLexiconBuilder<'a, S: resolve_lexicon_state::State> {
57 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
58 __unsafe_private_named: (
59 ::core::option::Option<jacquard_common::types::string::Nsid<'a>>,
60 ),
61 _phantom: ::core::marker::PhantomData<&'a ()>,
62}
63
64impl<'a> ResolveLexicon<'a> {
65 /// Create a new builder for this type
66 pub fn new() -> ResolveLexiconBuilder<'a, resolve_lexicon_state::Empty> {
67 ResolveLexiconBuilder::new()
68 }
69}
70
71impl<'a> ResolveLexiconBuilder<'a, resolve_lexicon_state::Empty> {
72 /// Create a new builder with all fields unset
73 pub fn new() -> Self {
74 ResolveLexiconBuilder {
75 _phantom_state: ::core::marker::PhantomData,
76 __unsafe_private_named: (None,),
77 _phantom: ::core::marker::PhantomData,
78 }
79 }
80}
81
82impl<'a, S> ResolveLexiconBuilder<'a, S>
83where
84 S: resolve_lexicon_state::State,
85 S::Nsid: resolve_lexicon_state::IsUnset,
86{
87 /// Set the `nsid` field (required)
88 pub fn nsid(
89 mut self,
90 value: impl Into<jacquard_common::types::string::Nsid<'a>>,
91 ) -> ResolveLexiconBuilder<'a, resolve_lexicon_state::SetNsid<S>> {
92 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
93 ResolveLexiconBuilder {
94 _phantom_state: ::core::marker::PhantomData,
95 __unsafe_private_named: self.__unsafe_private_named,
96 _phantom: ::core::marker::PhantomData,
97 }
98 }
99}
100
101impl<'a, S> ResolveLexiconBuilder<'a, S>
102where
103 S: resolve_lexicon_state::State,
104 S::Nsid: resolve_lexicon_state::IsSet,
105{
106 /// Build the final struct
107 pub fn build(self) -> ResolveLexicon<'a> {
108 ResolveLexicon {
109 nsid: self.__unsafe_private_named.0.unwrap(),
110 }
111 }
112}
113
114#[jacquard_derive::lexicon]
115#[derive(
116 serde::Serialize,
117 serde::Deserialize,
118 Debug,
119 Clone,
120 PartialEq,
121 Eq,
122 jacquard_derive::IntoStatic
123)]
124#[serde(rename_all = "camelCase")]
125pub struct ResolveLexiconOutput<'a> {
126 /// The CID of the lexicon schema record.
127 #[serde(borrow)]
128 pub cid: jacquard_common::types::string::Cid<'a>,
129 /// The resolved lexicon schema record.
130 #[serde(borrow)]
131 pub schema: crate::com_atproto::lexicon::schema::Schema<'a>,
132 /// The AT-URI of the lexicon schema record.
133 #[serde(borrow)]
134 pub uri: jacquard_common::types::string::AtUri<'a>,
135}
136
137#[jacquard_derive::open_union]
138#[derive(
139 serde::Serialize,
140 serde::Deserialize,
141 Debug,
142 Clone,
143 PartialEq,
144 Eq,
145 thiserror::Error,
146 miette::Diagnostic,
147 jacquard_derive::IntoStatic
148)]
149#[serde(tag = "error", content = "message")]
150#[serde(bound(deserialize = "'de: 'a"))]
151pub enum ResolveLexiconError<'a> {
152 /// No lexicon was resolved for the NSID.
153 #[serde(rename = "LexiconNotFound")]
154 LexiconNotFound(std::option::Option<jacquard_common::CowStr<'a>>),
155}
156
157impl core::fmt::Display for ResolveLexiconError<'_> {
158 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
159 match self {
160 Self::LexiconNotFound(msg) => {
161 write!(f, "LexiconNotFound")?;
162 if let Some(msg) = msg {
163 write!(f, ": {}", msg)?;
164 }
165 Ok(())
166 }
167 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
168 }
169 }
170}
171
172/// Response type for
173///com.atproto.lexicon.resolveLexicon
174pub struct ResolveLexiconResponse;
175impl jacquard_common::xrpc::XrpcResp for ResolveLexiconResponse {
176 const NSID: &'static str = "com.atproto.lexicon.resolveLexicon";
177 const ENCODING: &'static str = "application/json";
178 type Output<'de> = ResolveLexiconOutput<'de>;
179 type Err<'de> = ResolveLexiconError<'de>;
180}
181
182impl<'a> jacquard_common::xrpc::XrpcRequest for ResolveLexicon<'a> {
183 const NSID: &'static str = "com.atproto.lexicon.resolveLexicon";
184 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
185 type Response = ResolveLexiconResponse;
186}
187
188/// Endpoint type for
189///com.atproto.lexicon.resolveLexicon
190pub struct ResolveLexiconRequest;
191impl jacquard_common::xrpc::XrpcEndpoint for ResolveLexiconRequest {
192 const PATH: &'static str = "/xrpc/com.atproto.lexicon.resolveLexicon";
193 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
194 type Request<'de> = ResolveLexicon<'de>;
195 type Response = ResolveLexiconResponse;
196}