atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.identity.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod get_recommended_did_credentials;
9pub mod refresh_identity;
10pub mod request_plc_operation_signature;
11pub mod resolve_did;
12pub mod resolve_handle;
13pub mod resolve_identity;
14pub mod sign_plc_operation;
15pub mod submit_plc_operation;
16pub mod update_handle;
17
18#[jacquard_derive::lexicon]
19#[derive(
20 serde::Serialize,
21 serde::Deserialize,
22 Debug,
23 Clone,
24 PartialEq,
25 Eq,
26 jacquard_derive::IntoStatic
27)]
28#[serde(rename_all = "camelCase")]
29pub struct IdentityInfo<'a> {
30 #[serde(borrow)]
31 pub did: jacquard_common::types::string::Did<'a>,
32 /// The complete DID document for the identity.
33 #[serde(borrow)]
34 pub did_doc: jacquard_common::types::value::Data<'a>,
35 /// The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.
36 #[serde(borrow)]
37 pub handle: jacquard_common::types::string::Handle<'a>,
38}
39
40pub mod identity_info_state {
41
42 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
43 #[allow(unused)]
44 use ::core::marker::PhantomData;
45 mod sealed {
46 pub trait Sealed {}
47 }
48 /// State trait tracking which required fields have been set
49 pub trait State: sealed::Sealed {
50 type Did;
51 type DidDoc;
52 type Handle;
53 }
54 /// Empty state - all required fields are unset
55 pub struct Empty(());
56 impl sealed::Sealed for Empty {}
57 impl State for Empty {
58 type Did = Unset;
59 type DidDoc = Unset;
60 type Handle = Unset;
61 }
62 ///State transition - sets the `did` field to Set
63 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
64 impl<S: State> sealed::Sealed for SetDid<S> {}
65 impl<S: State> State for SetDid<S> {
66 type Did = Set<members::did>;
67 type DidDoc = S::DidDoc;
68 type Handle = S::Handle;
69 }
70 ///State transition - sets the `did_doc` field to Set
71 pub struct SetDidDoc<S: State = Empty>(PhantomData<fn() -> S>);
72 impl<S: State> sealed::Sealed for SetDidDoc<S> {}
73 impl<S: State> State for SetDidDoc<S> {
74 type Did = S::Did;
75 type DidDoc = Set<members::did_doc>;
76 type Handle = S::Handle;
77 }
78 ///State transition - sets the `handle` field to Set
79 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
80 impl<S: State> sealed::Sealed for SetHandle<S> {}
81 impl<S: State> State for SetHandle<S> {
82 type Did = S::Did;
83 type DidDoc = S::DidDoc;
84 type Handle = Set<members::handle>;
85 }
86 /// Marker types for field names
87 #[allow(non_camel_case_types)]
88 pub mod members {
89 ///Marker type for the `did` field
90 pub struct did(());
91 ///Marker type for the `did_doc` field
92 pub struct did_doc(());
93 ///Marker type for the `handle` field
94 pub struct handle(());
95 }
96}
97
98/// Builder for constructing an instance of this type
99pub struct IdentityInfoBuilder<'a, S: identity_info_state::State> {
100 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
101 __unsafe_private_named: (
102 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
103 ::core::option::Option<jacquard_common::types::value::Data<'a>>,
104 ::core::option::Option<jacquard_common::types::string::Handle<'a>>,
105 ),
106 _phantom: ::core::marker::PhantomData<&'a ()>,
107}
108
109impl<'a> IdentityInfo<'a> {
110 /// Create a new builder for this type
111 pub fn new() -> IdentityInfoBuilder<'a, identity_info_state::Empty> {
112 IdentityInfoBuilder::new()
113 }
114}
115
116impl<'a> IdentityInfoBuilder<'a, identity_info_state::Empty> {
117 /// Create a new builder with all fields unset
118 pub fn new() -> Self {
119 IdentityInfoBuilder {
120 _phantom_state: ::core::marker::PhantomData,
121 __unsafe_private_named: (None, None, None),
122 _phantom: ::core::marker::PhantomData,
123 }
124 }
125}
126
127impl<'a, S> IdentityInfoBuilder<'a, S>
128where
129 S: identity_info_state::State,
130 S::Did: identity_info_state::IsUnset,
131{
132 /// Set the `did` field (required)
133 pub fn did(
134 mut self,
135 value: impl Into<jacquard_common::types::string::Did<'a>>,
136 ) -> IdentityInfoBuilder<'a, identity_info_state::SetDid<S>> {
137 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
138 IdentityInfoBuilder {
139 _phantom_state: ::core::marker::PhantomData,
140 __unsafe_private_named: self.__unsafe_private_named,
141 _phantom: ::core::marker::PhantomData,
142 }
143 }
144}
145
146impl<'a, S> IdentityInfoBuilder<'a, S>
147where
148 S: identity_info_state::State,
149 S::DidDoc: identity_info_state::IsUnset,
150{
151 /// Set the `didDoc` field (required)
152 pub fn did_doc(
153 mut self,
154 value: impl Into<jacquard_common::types::value::Data<'a>>,
155 ) -> IdentityInfoBuilder<'a, identity_info_state::SetDidDoc<S>> {
156 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
157 IdentityInfoBuilder {
158 _phantom_state: ::core::marker::PhantomData,
159 __unsafe_private_named: self.__unsafe_private_named,
160 _phantom: ::core::marker::PhantomData,
161 }
162 }
163}
164
165impl<'a, S> IdentityInfoBuilder<'a, S>
166where
167 S: identity_info_state::State,
168 S::Handle: identity_info_state::IsUnset,
169{
170 /// Set the `handle` field (required)
171 pub fn handle(
172 mut self,
173 value: impl Into<jacquard_common::types::string::Handle<'a>>,
174 ) -> IdentityInfoBuilder<'a, identity_info_state::SetHandle<S>> {
175 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
176 IdentityInfoBuilder {
177 _phantom_state: ::core::marker::PhantomData,
178 __unsafe_private_named: self.__unsafe_private_named,
179 _phantom: ::core::marker::PhantomData,
180 }
181 }
182}
183
184impl<'a, S> IdentityInfoBuilder<'a, S>
185where
186 S: identity_info_state::State,
187 S::Did: identity_info_state::IsSet,
188 S::DidDoc: identity_info_state::IsSet,
189 S::Handle: identity_info_state::IsSet,
190{
191 /// Build the final struct
192 pub fn build(self) -> IdentityInfo<'a> {
193 IdentityInfo {
194 did: self.__unsafe_private_named.0.unwrap(),
195 did_doc: self.__unsafe_private_named.1.unwrap(),
196 handle: self.__unsafe_private_named.2.unwrap(),
197 extra_data: Default::default(),
198 }
199 }
200 /// Build the final struct with custom extra_data
201 pub fn build_with_data(
202 self,
203 extra_data: std::collections::BTreeMap<
204 jacquard_common::smol_str::SmolStr,
205 jacquard_common::types::value::Data<'a>,
206 >,
207 ) -> IdentityInfo<'a> {
208 IdentityInfo {
209 did: self.__unsafe_private_named.0.unwrap(),
210 did_doc: self.__unsafe_private_named.1.unwrap(),
211 handle: self.__unsafe_private_named.2.unwrap(),
212 extra_data: Some(extra_data),
213 }
214 }
215}
216
217fn lexicon_doc_com_atproto_identity_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
218 'static,
219> {
220 ::jacquard_lexicon::lexicon::LexiconDoc {
221 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
222 id: ::jacquard_common::CowStr::new_static("com.atproto.identity.defs"),
223 revision: None,
224 description: None,
225 defs: {
226 let mut map = ::alloc::collections::BTreeMap::new();
227 map.insert(
228 ::jacquard_common::smol_str::SmolStr::new_static("identityInfo"),
229 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
230 description: None,
231 required: Some(
232 vec![
233 ::jacquard_common::smol_str::SmolStr::new_static("did"),
234 ::jacquard_common::smol_str::SmolStr::new_static("handle"),
235 ::jacquard_common::smol_str::SmolStr::new_static("didDoc")
236 ],
237 ),
238 nullable: None,
239 properties: {
240 #[allow(unused_mut)]
241 let mut map = ::alloc::collections::BTreeMap::new();
242 map.insert(
243 ::jacquard_common::smol_str::SmolStr::new_static("did"),
244 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
245 description: None,
246 format: Some(
247 ::jacquard_lexicon::lexicon::LexStringFormat::Did,
248 ),
249 default: None,
250 min_length: None,
251 max_length: None,
252 min_graphemes: None,
253 max_graphemes: None,
254 r#enum: None,
255 r#const: None,
256 known_values: None,
257 }),
258 );
259 map.insert(
260 ::jacquard_common::smol_str::SmolStr::new_static("didDoc"),
261 ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown {
262 description: None,
263 }),
264 );
265 map.insert(
266 ::jacquard_common::smol_str::SmolStr::new_static("handle"),
267 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
268 description: Some(
269 ::jacquard_common::CowStr::new_static(
270 "The validated handle of the account; or 'handle.invalid' if the handle did not bi-directionally match the DID document.",
271 ),
272 ),
273 format: Some(
274 ::jacquard_lexicon::lexicon::LexStringFormat::Handle,
275 ),
276 default: None,
277 min_length: None,
278 max_length: None,
279 min_graphemes: None,
280 max_graphemes: None,
281 r#enum: None,
282 r#const: None,
283 known_values: None,
284 }),
285 );
286 map
287 },
288 }),
289 );
290 map
291 },
292 }
293}
294
295impl<'a> ::jacquard_lexicon::schema::LexiconSchema for IdentityInfo<'a> {
296 fn nsid() -> &'static str {
297 "com.atproto.identity.defs"
298 }
299 fn def_name() -> &'static str {
300 "identityInfo"
301 }
302 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
303 lexicon_doc_com_atproto_identity_defs()
304 }
305 fn validate(
306 &self,
307 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
308 Ok(())
309 }
310}