jacquard_api/com_atproto/server/
create_invite_codes.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.server.createInviteCodes
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct AccountCodes<'a> {
20    #[serde(borrow)]
21    pub account: jacquard_common::CowStr<'a>,
22    #[serde(borrow)]
23    pub codes: Vec<jacquard_common::CowStr<'a>>,
24}
25
26pub mod account_codes_state {
27
28    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
29    #[allow(unused)]
30    use ::core::marker::PhantomData;
31    mod sealed {
32        pub trait Sealed {}
33    }
34    /// State trait tracking which required fields have been set
35    pub trait State: sealed::Sealed {
36        type Account;
37        type Codes;
38    }
39    /// Empty state - all required fields are unset
40    pub struct Empty(());
41    impl sealed::Sealed for Empty {}
42    impl State for Empty {
43        type Account = Unset;
44        type Codes = Unset;
45    }
46    ///State transition - sets the `account` field to Set
47    pub struct SetAccount<S: State = Empty>(PhantomData<fn() -> S>);
48    impl<S: State> sealed::Sealed for SetAccount<S> {}
49    impl<S: State> State for SetAccount<S> {
50        type Account = Set<members::account>;
51        type Codes = S::Codes;
52    }
53    ///State transition - sets the `codes` field to Set
54    pub struct SetCodes<S: State = Empty>(PhantomData<fn() -> S>);
55    impl<S: State> sealed::Sealed for SetCodes<S> {}
56    impl<S: State> State for SetCodes<S> {
57        type Account = S::Account;
58        type Codes = Set<members::codes>;
59    }
60    /// Marker types for field names
61    #[allow(non_camel_case_types)]
62    pub mod members {
63        ///Marker type for the `account` field
64        pub struct account(());
65        ///Marker type for the `codes` field
66        pub struct codes(());
67    }
68}
69
70/// Builder for constructing an instance of this type
71pub struct AccountCodesBuilder<'a, S: account_codes_state::State> {
72    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
73    __unsafe_private_named: (
74        ::core::option::Option<jacquard_common::CowStr<'a>>,
75        ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
76    ),
77    _phantom: ::core::marker::PhantomData<&'a ()>,
78}
79
80impl<'a> AccountCodes<'a> {
81    /// Create a new builder for this type
82    pub fn new() -> AccountCodesBuilder<'a, account_codes_state::Empty> {
83        AccountCodesBuilder::new()
84    }
85}
86
87impl<'a> AccountCodesBuilder<'a, account_codes_state::Empty> {
88    /// Create a new builder with all fields unset
89    pub fn new() -> Self {
90        AccountCodesBuilder {
91            _phantom_state: ::core::marker::PhantomData,
92            __unsafe_private_named: (None, None),
93            _phantom: ::core::marker::PhantomData,
94        }
95    }
96}
97
98impl<'a, S> AccountCodesBuilder<'a, S>
99where
100    S: account_codes_state::State,
101    S::Account: account_codes_state::IsUnset,
102{
103    /// Set the `account` field (required)
104    pub fn account(
105        mut self,
106        value: impl Into<jacquard_common::CowStr<'a>>,
107    ) -> AccountCodesBuilder<'a, account_codes_state::SetAccount<S>> {
108        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
109        AccountCodesBuilder {
110            _phantom_state: ::core::marker::PhantomData,
111            __unsafe_private_named: self.__unsafe_private_named,
112            _phantom: ::core::marker::PhantomData,
113        }
114    }
115}
116
117impl<'a, S> AccountCodesBuilder<'a, S>
118where
119    S: account_codes_state::State,
120    S::Codes: account_codes_state::IsUnset,
121{
122    /// Set the `codes` field (required)
123    pub fn codes(
124        mut self,
125        value: impl Into<Vec<jacquard_common::CowStr<'a>>>,
126    ) -> AccountCodesBuilder<'a, account_codes_state::SetCodes<S>> {
127        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
128        AccountCodesBuilder {
129            _phantom_state: ::core::marker::PhantomData,
130            __unsafe_private_named: self.__unsafe_private_named,
131            _phantom: ::core::marker::PhantomData,
132        }
133    }
134}
135
136impl<'a, S> AccountCodesBuilder<'a, S>
137where
138    S: account_codes_state::State,
139    S::Account: account_codes_state::IsSet,
140    S::Codes: account_codes_state::IsSet,
141{
142    /// Build the final struct
143    pub fn build(self) -> AccountCodes<'a> {
144        AccountCodes {
145            account: self.__unsafe_private_named.0.unwrap(),
146            codes: self.__unsafe_private_named.1.unwrap(),
147            extra_data: Default::default(),
148        }
149    }
150    /// Build the final struct with custom extra_data
151    pub fn build_with_data(
152        self,
153        extra_data: std::collections::BTreeMap<
154            jacquard_common::smol_str::SmolStr,
155            jacquard_common::types::value::Data<'a>,
156        >,
157    ) -> AccountCodes<'a> {
158        AccountCodes {
159            account: self.__unsafe_private_named.0.unwrap(),
160            codes: self.__unsafe_private_named.1.unwrap(),
161            extra_data: Some(extra_data),
162        }
163    }
164}
165
166fn lexicon_doc_com_atproto_server_createInviteCodes() -> ::jacquard_lexicon::lexicon::LexiconDoc<
167    'static,
168> {
169    ::jacquard_lexicon::lexicon::LexiconDoc {
170        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
171        id: ::jacquard_common::CowStr::new_static(
172            "com.atproto.server.createInviteCodes",
173        ),
174        revision: None,
175        description: None,
176        defs: {
177            let mut map = ::std::collections::BTreeMap::new();
178            map.insert(
179                ::jacquard_common::smol_str::SmolStr::new_static("accountCodes"),
180                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
181                    description: None,
182                    required: Some(
183                        vec![
184                            ::jacquard_common::smol_str::SmolStr::new_static("account"),
185                            ::jacquard_common::smol_str::SmolStr::new_static("codes")
186                        ],
187                    ),
188                    nullable: None,
189                    properties: {
190                        #[allow(unused_mut)]
191                        let mut map = ::std::collections::BTreeMap::new();
192                        map.insert(
193                            ::jacquard_common::smol_str::SmolStr::new_static("account"),
194                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
195                                description: None,
196                                format: None,
197                                default: None,
198                                min_length: None,
199                                max_length: None,
200                                min_graphemes: None,
201                                max_graphemes: None,
202                                r#enum: None,
203                                r#const: None,
204                                known_values: None,
205                            }),
206                        );
207                        map.insert(
208                            ::jacquard_common::smol_str::SmolStr::new_static("codes"),
209                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
210                                description: None,
211                                items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
212                                    description: None,
213                                    format: None,
214                                    default: None,
215                                    min_length: None,
216                                    max_length: None,
217                                    min_graphemes: None,
218                                    max_graphemes: None,
219                                    r#enum: None,
220                                    r#const: None,
221                                    known_values: None,
222                                }),
223                                min_length: None,
224                                max_length: None,
225                            }),
226                        );
227                        map
228                    },
229                }),
230            );
231            map.insert(
232                ::jacquard_common::smol_str::SmolStr::new_static("main"),
233                ::jacquard_lexicon::lexicon::LexUserType::XrpcProcedure(::jacquard_lexicon::lexicon::LexXrpcProcedure {
234                    description: None,
235                    parameters: None,
236                    input: Some(::jacquard_lexicon::lexicon::LexXrpcBody {
237                        description: None,
238                        encoding: ::jacquard_common::CowStr::new_static(
239                            "application/json",
240                        ),
241                        schema: Some(
242                            ::jacquard_lexicon::lexicon::LexXrpcBodySchema::Object(::jacquard_lexicon::lexicon::LexObject {
243                                description: None,
244                                required: Some(
245                                    vec![
246                                        ::jacquard_common::smol_str::SmolStr::new_static("codeCount"),
247                                        ::jacquard_common::smol_str::SmolStr::new_static("useCount")
248                                    ],
249                                ),
250                                nullable: None,
251                                properties: {
252                                    #[allow(unused_mut)]
253                                    let mut map = ::std::collections::BTreeMap::new();
254                                    map.insert(
255                                        ::jacquard_common::smol_str::SmolStr::new_static(
256                                            "codeCount",
257                                        ),
258                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
259                                            description: None,
260                                            default: None,
261                                            minimum: None,
262                                            maximum: None,
263                                            r#enum: None,
264                                            r#const: None,
265                                        }),
266                                    );
267                                    map.insert(
268                                        ::jacquard_common::smol_str::SmolStr::new_static(
269                                            "forAccounts",
270                                        ),
271                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
272                                            description: None,
273                                            items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
274                                                description: None,
275                                                format: Some(
276                                                    ::jacquard_lexicon::lexicon::LexStringFormat::Did,
277                                                ),
278                                                default: None,
279                                                min_length: None,
280                                                max_length: None,
281                                                min_graphemes: None,
282                                                max_graphemes: None,
283                                                r#enum: None,
284                                                r#const: None,
285                                                known_values: None,
286                                            }),
287                                            min_length: None,
288                                            max_length: None,
289                                        }),
290                                    );
291                                    map.insert(
292                                        ::jacquard_common::smol_str::SmolStr::new_static(
293                                            "useCount",
294                                        ),
295                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
296                                            description: None,
297                                            default: None,
298                                            minimum: None,
299                                            maximum: None,
300                                            r#enum: None,
301                                            r#const: None,
302                                        }),
303                                    );
304                                    map
305                                },
306                            }),
307                        ),
308                    }),
309                    output: None,
310                    errors: None,
311                }),
312            );
313            map
314        },
315    }
316}
317
318impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AccountCodes<'a> {
319    fn nsid() -> &'static str {
320        "com.atproto.server.createInviteCodes"
321    }
322    fn def_name() -> &'static str {
323        "accountCodes"
324    }
325    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
326        lexicon_doc_com_atproto_server_createInviteCodes()
327    }
328    fn validate(
329        &self,
330    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
331        Ok(())
332    }
333}
334
335#[jacquard_derive::lexicon]
336#[derive(
337    serde::Serialize,
338    serde::Deserialize,
339    Debug,
340    Clone,
341    PartialEq,
342    Eq,
343    jacquard_derive::IntoStatic
344)]
345#[serde(rename_all = "camelCase")]
346pub struct CreateInviteCodes<'a> {
347    pub code_count: i64,
348    #[serde(skip_serializing_if = "std::option::Option::is_none")]
349    #[serde(borrow)]
350    pub for_accounts: Option<Vec<jacquard_common::types::string::Did<'a>>>,
351    pub use_count: i64,
352}
353
354pub mod create_invite_codes_state {
355
356    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
357    #[allow(unused)]
358    use ::core::marker::PhantomData;
359    mod sealed {
360        pub trait Sealed {}
361    }
362    /// State trait tracking which required fields have been set
363    pub trait State: sealed::Sealed {
364        type CodeCount;
365        type UseCount;
366    }
367    /// Empty state - all required fields are unset
368    pub struct Empty(());
369    impl sealed::Sealed for Empty {}
370    impl State for Empty {
371        type CodeCount = Unset;
372        type UseCount = Unset;
373    }
374    ///State transition - sets the `code_count` field to Set
375    pub struct SetCodeCount<S: State = Empty>(PhantomData<fn() -> S>);
376    impl<S: State> sealed::Sealed for SetCodeCount<S> {}
377    impl<S: State> State for SetCodeCount<S> {
378        type CodeCount = Set<members::code_count>;
379        type UseCount = S::UseCount;
380    }
381    ///State transition - sets the `use_count` field to Set
382    pub struct SetUseCount<S: State = Empty>(PhantomData<fn() -> S>);
383    impl<S: State> sealed::Sealed for SetUseCount<S> {}
384    impl<S: State> State for SetUseCount<S> {
385        type CodeCount = S::CodeCount;
386        type UseCount = Set<members::use_count>;
387    }
388    /// Marker types for field names
389    #[allow(non_camel_case_types)]
390    pub mod members {
391        ///Marker type for the `code_count` field
392        pub struct code_count(());
393        ///Marker type for the `use_count` field
394        pub struct use_count(());
395    }
396}
397
398/// Builder for constructing an instance of this type
399pub struct CreateInviteCodesBuilder<'a, S: create_invite_codes_state::State> {
400    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
401    __unsafe_private_named: (
402        ::core::option::Option<i64>,
403        ::core::option::Option<Vec<jacquard_common::types::string::Did<'a>>>,
404        ::core::option::Option<i64>,
405    ),
406    _phantom: ::core::marker::PhantomData<&'a ()>,
407}
408
409impl<'a> CreateInviteCodes<'a> {
410    /// Create a new builder for this type
411    pub fn new() -> CreateInviteCodesBuilder<'a, create_invite_codes_state::Empty> {
412        CreateInviteCodesBuilder::new()
413    }
414}
415
416impl<'a> CreateInviteCodesBuilder<'a, create_invite_codes_state::Empty> {
417    /// Create a new builder with all fields unset
418    pub fn new() -> Self {
419        CreateInviteCodesBuilder {
420            _phantom_state: ::core::marker::PhantomData,
421            __unsafe_private_named: (None, None, None),
422            _phantom: ::core::marker::PhantomData,
423        }
424    }
425}
426
427impl<'a, S> CreateInviteCodesBuilder<'a, S>
428where
429    S: create_invite_codes_state::State,
430    S::CodeCount: create_invite_codes_state::IsUnset,
431{
432    /// Set the `codeCount` field (required)
433    pub fn code_count(
434        mut self,
435        value: impl Into<i64>,
436    ) -> CreateInviteCodesBuilder<'a, create_invite_codes_state::SetCodeCount<S>> {
437        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
438        CreateInviteCodesBuilder {
439            _phantom_state: ::core::marker::PhantomData,
440            __unsafe_private_named: self.__unsafe_private_named,
441            _phantom: ::core::marker::PhantomData,
442        }
443    }
444}
445
446impl<'a, S: create_invite_codes_state::State> CreateInviteCodesBuilder<'a, S> {
447    /// Set the `forAccounts` field (optional)
448    pub fn for_accounts(
449        mut self,
450        value: impl Into<Option<Vec<jacquard_common::types::string::Did<'a>>>>,
451    ) -> Self {
452        self.__unsafe_private_named.1 = value.into();
453        self
454    }
455    /// Set the `forAccounts` field to an Option value (optional)
456    pub fn maybe_for_accounts(
457        mut self,
458        value: Option<Vec<jacquard_common::types::string::Did<'a>>>,
459    ) -> Self {
460        self.__unsafe_private_named.1 = value;
461        self
462    }
463}
464
465impl<'a, S> CreateInviteCodesBuilder<'a, S>
466where
467    S: create_invite_codes_state::State,
468    S::UseCount: create_invite_codes_state::IsUnset,
469{
470    /// Set the `useCount` field (required)
471    pub fn use_count(
472        mut self,
473        value: impl Into<i64>,
474    ) -> CreateInviteCodesBuilder<'a, create_invite_codes_state::SetUseCount<S>> {
475        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
476        CreateInviteCodesBuilder {
477            _phantom_state: ::core::marker::PhantomData,
478            __unsafe_private_named: self.__unsafe_private_named,
479            _phantom: ::core::marker::PhantomData,
480        }
481    }
482}
483
484impl<'a, S> CreateInviteCodesBuilder<'a, S>
485where
486    S: create_invite_codes_state::State,
487    S::CodeCount: create_invite_codes_state::IsSet,
488    S::UseCount: create_invite_codes_state::IsSet,
489{
490    /// Build the final struct
491    pub fn build(self) -> CreateInviteCodes<'a> {
492        CreateInviteCodes {
493            code_count: self.__unsafe_private_named.0.unwrap(),
494            for_accounts: self.__unsafe_private_named.1,
495            use_count: self.__unsafe_private_named.2.unwrap(),
496            extra_data: Default::default(),
497        }
498    }
499    /// Build the final struct with custom extra_data
500    pub fn build_with_data(
501        self,
502        extra_data: std::collections::BTreeMap<
503            jacquard_common::smol_str::SmolStr,
504            jacquard_common::types::value::Data<'a>,
505        >,
506    ) -> CreateInviteCodes<'a> {
507        CreateInviteCodes {
508            code_count: self.__unsafe_private_named.0.unwrap(),
509            for_accounts: self.__unsafe_private_named.1,
510            use_count: self.__unsafe_private_named.2.unwrap(),
511            extra_data: Some(extra_data),
512        }
513    }
514}
515
516#[jacquard_derive::lexicon]
517#[derive(
518    serde::Serialize,
519    serde::Deserialize,
520    Debug,
521    Clone,
522    PartialEq,
523    Eq,
524    jacquard_derive::IntoStatic
525)]
526#[serde(rename_all = "camelCase")]
527pub struct CreateInviteCodesOutput<'a> {
528    #[serde(borrow)]
529    pub codes: Vec<crate::com_atproto::server::create_invite_codes::AccountCodes<'a>>,
530}
531
532/// Response type for
533///com.atproto.server.createInviteCodes
534pub struct CreateInviteCodesResponse;
535impl jacquard_common::xrpc::XrpcResp for CreateInviteCodesResponse {
536    const NSID: &'static str = "com.atproto.server.createInviteCodes";
537    const ENCODING: &'static str = "application/json";
538    type Output<'de> = CreateInviteCodesOutput<'de>;
539    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
540}
541
542impl<'a> jacquard_common::xrpc::XrpcRequest for CreateInviteCodes<'a> {
543    const NSID: &'static str = "com.atproto.server.createInviteCodes";
544    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
545        "application/json",
546    );
547    type Response = CreateInviteCodesResponse;
548}
549
550/// Endpoint type for
551///com.atproto.server.createInviteCodes
552pub struct CreateInviteCodesRequest;
553impl jacquard_common::xrpc::XrpcEndpoint for CreateInviteCodesRequest {
554    const PATH: &'static str = "/xrpc/com.atproto.server.createInviteCodes";
555    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
556        "application/json",
557    );
558    type Request<'de> = CreateInviteCodes<'de>;
559    type Response = CreateInviteCodesResponse;
560}