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