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