Skip to main content

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