atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.verification
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record declaring a verification relationship between two accounts. Verifications are only considered valid by an app if issued by an account the app considers trusted.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Verification<'a> {
21 /// Date of when the verification was created.
22 pub created_at: jacquard_common::types::string::Datetime,
23 /// Display name of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current displayName matches the one at the time of verifying.
24 #[serde(borrow)]
25 pub display_name: jacquard_common::CowStr<'a>,
26 /// Handle of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current handle matches the one at the time of verifying.
27 #[serde(borrow)]
28 pub handle: jacquard_common::types::string::Handle<'a>,
29 /// DID of the subject the verification applies to.
30 #[serde(borrow)]
31 pub subject: jacquard_common::types::string::Did<'a>,
32}
33
34pub mod verification_state {
35
36 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
37 #[allow(unused)]
38 use ::core::marker::PhantomData;
39 mod sealed {
40 pub trait Sealed {}
41 }
42 /// State trait tracking which required fields have been set
43 pub trait State: sealed::Sealed {
44 type Handle;
45 type CreatedAt;
46 type Subject;
47 type DisplayName;
48 }
49 /// Empty state - all required fields are unset
50 pub struct Empty(());
51 impl sealed::Sealed for Empty {}
52 impl State for Empty {
53 type Handle = Unset;
54 type CreatedAt = Unset;
55 type Subject = Unset;
56 type DisplayName = Unset;
57 }
58 ///State transition - sets the `handle` field to Set
59 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
60 impl<S: State> sealed::Sealed for SetHandle<S> {}
61 impl<S: State> State for SetHandle<S> {
62 type Handle = Set<members::handle>;
63 type CreatedAt = S::CreatedAt;
64 type Subject = S::Subject;
65 type DisplayName = S::DisplayName;
66 }
67 ///State transition - sets the `created_at` field to Set
68 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
69 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
70 impl<S: State> State for SetCreatedAt<S> {
71 type Handle = S::Handle;
72 type CreatedAt = Set<members::created_at>;
73 type Subject = S::Subject;
74 type DisplayName = S::DisplayName;
75 }
76 ///State transition - sets the `subject` field to Set
77 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
78 impl<S: State> sealed::Sealed for SetSubject<S> {}
79 impl<S: State> State for SetSubject<S> {
80 type Handle = S::Handle;
81 type CreatedAt = S::CreatedAt;
82 type Subject = Set<members::subject>;
83 type DisplayName = S::DisplayName;
84 }
85 ///State transition - sets the `display_name` field to Set
86 pub struct SetDisplayName<S: State = Empty>(PhantomData<fn() -> S>);
87 impl<S: State> sealed::Sealed for SetDisplayName<S> {}
88 impl<S: State> State for SetDisplayName<S> {
89 type Handle = S::Handle;
90 type CreatedAt = S::CreatedAt;
91 type Subject = S::Subject;
92 type DisplayName = Set<members::display_name>;
93 }
94 /// Marker types for field names
95 #[allow(non_camel_case_types)]
96 pub mod members {
97 ///Marker type for the `handle` field
98 pub struct handle(());
99 ///Marker type for the `created_at` field
100 pub struct created_at(());
101 ///Marker type for the `subject` field
102 pub struct subject(());
103 ///Marker type for the `display_name` field
104 pub struct display_name(());
105 }
106}
107
108/// Builder for constructing an instance of this type
109pub struct VerificationBuilder<'a, S: verification_state::State> {
110 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
111 __unsafe_private_named: (
112 ::core::option::Option<jacquard_common::types::string::Datetime>,
113 ::core::option::Option<jacquard_common::CowStr<'a>>,
114 ::core::option::Option<jacquard_common::types::string::Handle<'a>>,
115 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
116 ),
117 _phantom: ::core::marker::PhantomData<&'a ()>,
118}
119
120impl<'a> Verification<'a> {
121 /// Create a new builder for this type
122 pub fn new() -> VerificationBuilder<'a, verification_state::Empty> {
123 VerificationBuilder::new()
124 }
125}
126
127impl<'a> VerificationBuilder<'a, verification_state::Empty> {
128 /// Create a new builder with all fields unset
129 pub fn new() -> Self {
130 VerificationBuilder {
131 _phantom_state: ::core::marker::PhantomData,
132 __unsafe_private_named: (None, None, None, None),
133 _phantom: ::core::marker::PhantomData,
134 }
135 }
136}
137
138impl<'a, S> VerificationBuilder<'a, S>
139where
140 S: verification_state::State,
141 S::CreatedAt: verification_state::IsUnset,
142{
143 /// Set the `createdAt` field (required)
144 pub fn created_at(
145 mut self,
146 value: impl Into<jacquard_common::types::string::Datetime>,
147 ) -> VerificationBuilder<'a, verification_state::SetCreatedAt<S>> {
148 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
149 VerificationBuilder {
150 _phantom_state: ::core::marker::PhantomData,
151 __unsafe_private_named: self.__unsafe_private_named,
152 _phantom: ::core::marker::PhantomData,
153 }
154 }
155}
156
157impl<'a, S> VerificationBuilder<'a, S>
158where
159 S: verification_state::State,
160 S::DisplayName: verification_state::IsUnset,
161{
162 /// Set the `displayName` field (required)
163 pub fn display_name(
164 mut self,
165 value: impl Into<jacquard_common::CowStr<'a>>,
166 ) -> VerificationBuilder<'a, verification_state::SetDisplayName<S>> {
167 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
168 VerificationBuilder {
169 _phantom_state: ::core::marker::PhantomData,
170 __unsafe_private_named: self.__unsafe_private_named,
171 _phantom: ::core::marker::PhantomData,
172 }
173 }
174}
175
176impl<'a, S> VerificationBuilder<'a, S>
177where
178 S: verification_state::State,
179 S::Handle: verification_state::IsUnset,
180{
181 /// Set the `handle` field (required)
182 pub fn handle(
183 mut self,
184 value: impl Into<jacquard_common::types::string::Handle<'a>>,
185 ) -> VerificationBuilder<'a, verification_state::SetHandle<S>> {
186 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
187 VerificationBuilder {
188 _phantom_state: ::core::marker::PhantomData,
189 __unsafe_private_named: self.__unsafe_private_named,
190 _phantom: ::core::marker::PhantomData,
191 }
192 }
193}
194
195impl<'a, S> VerificationBuilder<'a, S>
196where
197 S: verification_state::State,
198 S::Subject: verification_state::IsUnset,
199{
200 /// Set the `subject` field (required)
201 pub fn subject(
202 mut self,
203 value: impl Into<jacquard_common::types::string::Did<'a>>,
204 ) -> VerificationBuilder<'a, verification_state::SetSubject<S>> {
205 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
206 VerificationBuilder {
207 _phantom_state: ::core::marker::PhantomData,
208 __unsafe_private_named: self.__unsafe_private_named,
209 _phantom: ::core::marker::PhantomData,
210 }
211 }
212}
213
214impl<'a, S> VerificationBuilder<'a, S>
215where
216 S: verification_state::State,
217 S::Handle: verification_state::IsSet,
218 S::CreatedAt: verification_state::IsSet,
219 S::Subject: verification_state::IsSet,
220 S::DisplayName: verification_state::IsSet,
221{
222 /// Build the final struct
223 pub fn build(self) -> Verification<'a> {
224 Verification {
225 created_at: self.__unsafe_private_named.0.unwrap(),
226 display_name: self.__unsafe_private_named.1.unwrap(),
227 handle: self.__unsafe_private_named.2.unwrap(),
228 subject: self.__unsafe_private_named.3.unwrap(),
229 extra_data: Default::default(),
230 }
231 }
232 /// Build the final struct with custom extra_data
233 pub fn build_with_data(
234 self,
235 extra_data: std::collections::BTreeMap<
236 jacquard_common::smol_str::SmolStr,
237 jacquard_common::types::value::Data<'a>,
238 >,
239 ) -> Verification<'a> {
240 Verification {
241 created_at: self.__unsafe_private_named.0.unwrap(),
242 display_name: self.__unsafe_private_named.1.unwrap(),
243 handle: self.__unsafe_private_named.2.unwrap(),
244 subject: self.__unsafe_private_named.3.unwrap(),
245 extra_data: Some(extra_data),
246 }
247 }
248}
249
250impl<'a> Verification<'a> {
251 pub fn uri(
252 uri: impl Into<jacquard_common::CowStr<'a>>,
253 ) -> Result<
254 jacquard_common::types::uri::RecordUri<'a, VerificationRecord>,
255 jacquard_common::types::uri::UriError,
256 > {
257 jacquard_common::types::uri::RecordUri::try_from_uri(
258 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
259 )
260 }
261}
262
263/// Typed wrapper for GetRecord response with this collection's record type.
264#[derive(
265 serde::Serialize,
266 serde::Deserialize,
267 Debug,
268 Clone,
269 PartialEq,
270 Eq,
271 jacquard_derive::IntoStatic
272)]
273#[serde(rename_all = "camelCase")]
274pub struct VerificationGetRecordOutput<'a> {
275 #[serde(skip_serializing_if = "std::option::Option::is_none")]
276 #[serde(borrow)]
277 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
278 #[serde(borrow)]
279 pub uri: jacquard_common::types::string::AtUri<'a>,
280 #[serde(borrow)]
281 pub value: Verification<'a>,
282}
283
284impl From<VerificationGetRecordOutput<'_>> for Verification<'_> {
285 fn from(output: VerificationGetRecordOutput<'_>) -> Self {
286 use jacquard_common::IntoStatic;
287 output.value.into_static()
288 }
289}
290
291impl jacquard_common::types::collection::Collection for Verification<'_> {
292 const NSID: &'static str = "app.bsky.graph.verification";
293 type Record = VerificationRecord;
294}
295
296/// Marker type for deserializing records from this collection.
297#[derive(Debug, serde::Serialize, serde::Deserialize)]
298pub struct VerificationRecord;
299impl jacquard_common::xrpc::XrpcResp for VerificationRecord {
300 const NSID: &'static str = "app.bsky.graph.verification";
301 const ENCODING: &'static str = "application/json";
302 type Output<'de> = VerificationGetRecordOutput<'de>;
303 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
304}
305
306impl jacquard_common::types::collection::Collection for VerificationRecord {
307 const NSID: &'static str = "app.bsky.graph.verification";
308 type Record = VerificationRecord;
309}
310
311impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Verification<'a> {
312 fn nsid() -> &'static str {
313 "app.bsky.graph.verification"
314 }
315 fn def_name() -> &'static str {
316 "main"
317 }
318 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
319 lexicon_doc_app_bsky_graph_verification()
320 }
321 fn validate(
322 &self,
323 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
324 Ok(())
325 }
326}
327
328fn lexicon_doc_app_bsky_graph_verification() -> ::jacquard_lexicon::lexicon::LexiconDoc<
329 'static,
330> {
331 ::jacquard_lexicon::lexicon::LexiconDoc {
332 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
333 id: ::jacquard_common::CowStr::new_static("app.bsky.graph.verification"),
334 revision: None,
335 description: None,
336 defs: {
337 let mut map = ::alloc::collections::BTreeMap::new();
338 map.insert(
339 ::jacquard_common::smol_str::SmolStr::new_static("main"),
340 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
341 description: Some(
342 ::jacquard_common::CowStr::new_static(
343 "Record declaring a verification relationship between two accounts. Verifications are only considered valid by an app if issued by an account the app considers trusted.",
344 ),
345 ),
346 key: Some(::jacquard_common::CowStr::new_static("tid")),
347 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
348 description: None,
349 required: Some(
350 vec![
351 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
352 ::jacquard_common::smol_str::SmolStr::new_static("handle"),
353 ::jacquard_common::smol_str::SmolStr::new_static("displayName"),
354 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
355 ],
356 ),
357 nullable: None,
358 properties: {
359 #[allow(unused_mut)]
360 let mut map = ::alloc::collections::BTreeMap::new();
361 map.insert(
362 ::jacquard_common::smol_str::SmolStr::new_static(
363 "createdAt",
364 ),
365 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
366 description: Some(
367 ::jacquard_common::CowStr::new_static(
368 "Date of when the verification was created.",
369 ),
370 ),
371 format: Some(
372 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
373 ),
374 default: None,
375 min_length: None,
376 max_length: None,
377 min_graphemes: None,
378 max_graphemes: None,
379 r#enum: None,
380 r#const: None,
381 known_values: None,
382 }),
383 );
384 map.insert(
385 ::jacquard_common::smol_str::SmolStr::new_static(
386 "displayName",
387 ),
388 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
389 description: Some(
390 ::jacquard_common::CowStr::new_static(
391 "Display name of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current displayName matches the one at the time of verifying.",
392 ),
393 ),
394 format: None,
395 default: None,
396 min_length: None,
397 max_length: None,
398 min_graphemes: None,
399 max_graphemes: None,
400 r#enum: None,
401 r#const: None,
402 known_values: None,
403 }),
404 );
405 map.insert(
406 ::jacquard_common::smol_str::SmolStr::new_static("handle"),
407 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
408 description: Some(
409 ::jacquard_common::CowStr::new_static(
410 "Handle of the subject the verification applies to at the moment of verifying, which might not be the same at the time of viewing. The verification is only valid if the current handle matches the one at the time of verifying.",
411 ),
412 ),
413 format: Some(
414 ::jacquard_lexicon::lexicon::LexStringFormat::Handle,
415 ),
416 default: None,
417 min_length: None,
418 max_length: None,
419 min_graphemes: None,
420 max_graphemes: None,
421 r#enum: None,
422 r#const: None,
423 known_values: None,
424 }),
425 );
426 map.insert(
427 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
428 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
429 description: Some(
430 ::jacquard_common::CowStr::new_static(
431 "DID of the subject the verification applies to.",
432 ),
433 ),
434 format: Some(
435 ::jacquard_lexicon::lexicon::LexStringFormat::Did,
436 ),
437 default: None,
438 min_length: None,
439 max_length: None,
440 min_graphemes: None,
441 max_graphemes: None,
442 r#enum: None,
443 r#const: None,
444 known_values: None,
445 }),
446 );
447 map
448 },
449 }),
450 }),
451 );
452 map
453 },
454 }
455}