jacquard-api 0.10.2

Generated AT Protocol API bindings for Jacquard
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.atproto.server.createInviteCodes
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct AccountCodes<'a> {
    #[serde(borrow)]
    pub account: jacquard_common::CowStr<'a>,
    #[serde(borrow)]
    pub codes: Vec<jacquard_common::CowStr<'a>>,
}

pub mod account_codes_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Account;
        type Codes;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Account = Unset;
        type Codes = Unset;
    }
    ///State transition - sets the `account` field to Set
    pub struct SetAccount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAccount<S> {}
    impl<S: State> State for SetAccount<S> {
        type Account = Set<members::account>;
        type Codes = S::Codes;
    }
    ///State transition - sets the `codes` field to Set
    pub struct SetCodes<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCodes<S> {}
    impl<S: State> State for SetCodes<S> {
        type Account = S::Account;
        type Codes = Set<members::codes>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `account` field
        pub struct account(());
        ///Marker type for the `codes` field
        pub struct codes(());
    }
}

/// Builder for constructing an instance of this type
pub struct AccountCodesBuilder<'a, S: account_codes_state::State> {
    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
    __unsafe_private_named: (
        ::core::option::Option<jacquard_common::CowStr<'a>>,
        ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
    ),
    _phantom: ::core::marker::PhantomData<&'a ()>,
}

impl<'a> AccountCodes<'a> {
    /// Create a new builder for this type
    pub fn new() -> AccountCodesBuilder<'a, account_codes_state::Empty> {
        AccountCodesBuilder::new()
    }
}

impl<'a> AccountCodesBuilder<'a, account_codes_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        AccountCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: (None, None),
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> AccountCodesBuilder<'a, S>
where
    S: account_codes_state::State,
    S::Account: account_codes_state::IsUnset,
{
    /// Set the `account` field (required)
    pub fn account(
        mut self,
        value: impl Into<jacquard_common::CowStr<'a>>,
    ) -> AccountCodesBuilder<'a, account_codes_state::SetAccount<S>> {
        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
        AccountCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> AccountCodesBuilder<'a, S>
where
    S: account_codes_state::State,
    S::Codes: account_codes_state::IsUnset,
{
    /// Set the `codes` field (required)
    pub fn codes(
        mut self,
        value: impl Into<Vec<jacquard_common::CowStr<'a>>>,
    ) -> AccountCodesBuilder<'a, account_codes_state::SetCodes<S>> {
        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
        AccountCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> AccountCodesBuilder<'a, S>
where
    S: account_codes_state::State,
    S::Account: account_codes_state::IsSet,
    S::Codes: account_codes_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> AccountCodes<'a> {
        AccountCodes {
            account: self.__unsafe_private_named.0.unwrap(),
            codes: self.__unsafe_private_named.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: std::collections::BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> AccountCodes<'a> {
        AccountCodes {
            account: self.__unsafe_private_named.0.unwrap(),
            codes: self.__unsafe_private_named.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_com_atproto_server_createInviteCodes() -> ::jacquard_lexicon::lexicon::LexiconDoc<
    'static,
> {
    ::jacquard_lexicon::lexicon::LexiconDoc {
        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
        id: ::jacquard_common::CowStr::new_static(
            "com.atproto.server.createInviteCodes",
        ),
        revision: None,
        description: None,
        defs: {
            let mut map = ::alloc::collections::BTreeMap::new();
            map.insert(
                ::jacquard_common::deps::smol_str::SmolStr::new_static("accountCodes"),
                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
                    description: None,
                    required: Some(
                        vec![
                            ::jacquard_common::deps::smol_str::SmolStr::new_static("account"),
                            ::jacquard_common::deps::smol_str::SmolStr::new_static("codes")
                        ],
                    ),
                    nullable: None,
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = ::alloc::collections::BTreeMap::new();
                        map.insert(
                            ::jacquard_common::deps::smol_str::SmolStr::new_static(
                                "account",
                            ),
                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
                                description: None,
                                format: None,
                                default: None,
                                min_length: None,
                                max_length: None,
                                min_graphemes: None,
                                max_graphemes: None,
                                r#enum: None,
                                r#const: None,
                                known_values: None,
                            }),
                        );
                        map.insert(
                            ::jacquard_common::deps::smol_str::SmolStr::new_static(
                                "codes",
                            ),
                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
                                description: None,
                                items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
                                    description: None,
                                    format: None,
                                    default: None,
                                    min_length: None,
                                    max_length: None,
                                    min_graphemes: None,
                                    max_graphemes: None,
                                    r#enum: None,
                                    r#const: None,
                                    known_values: None,
                                }),
                                min_length: None,
                                max_length: None,
                            }),
                        );
                        map
                    },
                }),
            );
            map.insert(
                ::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
                ::jacquard_lexicon::lexicon::LexUserType::XrpcProcedure(::jacquard_lexicon::lexicon::LexXrpcProcedure {
                    description: None,
                    parameters: None,
                    input: Some(::jacquard_lexicon::lexicon::LexXrpcBody {
                        description: None,
                        encoding: ::jacquard_common::CowStr::new_static(
                            "application/json",
                        ),
                        schema: Some(
                            ::jacquard_lexicon::lexicon::LexXrpcBodySchema::Object(::jacquard_lexicon::lexicon::LexObject {
                                description: None,
                                required: Some(
                                    vec![
                                        ::jacquard_common::deps::smol_str::SmolStr::new_static("codeCount"),
                                        ::jacquard_common::deps::smol_str::SmolStr::new_static("useCount")
                                    ],
                                ),
                                nullable: None,
                                properties: {
                                    #[allow(unused_mut)]
                                    let mut map = ::alloc::collections::BTreeMap::new();
                                    map.insert(
                                        ::jacquard_common::deps::smol_str::SmolStr::new_static(
                                            "codeCount",
                                        ),
                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
                                            description: None,
                                            default: None,
                                            minimum: None,
                                            maximum: None,
                                            r#enum: None,
                                            r#const: None,
                                        }),
                                    );
                                    map.insert(
                                        ::jacquard_common::deps::smol_str::SmolStr::new_static(
                                            "forAccounts",
                                        ),
                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
                                            description: None,
                                            items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
                                                description: None,
                                                format: Some(
                                                    ::jacquard_lexicon::lexicon::LexStringFormat::Did,
                                                ),
                                                default: None,
                                                min_length: None,
                                                max_length: None,
                                                min_graphemes: None,
                                                max_graphemes: None,
                                                r#enum: None,
                                                r#const: None,
                                                known_values: None,
                                            }),
                                            min_length: None,
                                            max_length: None,
                                        }),
                                    );
                                    map.insert(
                                        ::jacquard_common::deps::smol_str::SmolStr::new_static(
                                            "useCount",
                                        ),
                                        ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
                                            description: None,
                                            default: None,
                                            minimum: None,
                                            maximum: None,
                                            r#enum: None,
                                            r#const: None,
                                        }),
                                    );
                                    map
                                },
                            }),
                        ),
                    }),
                    output: None,
                    errors: None,
                }),
            );
            map
        },
    }
}

impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AccountCodes<'a> {
    fn nsid() -> &'static str {
        "com.atproto.server.createInviteCodes"
    }
    fn def_name() -> &'static str {
        "accountCodes"
    }
    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
        lexicon_doc_com_atproto_server_createInviteCodes()
    }
    fn validate(
        &self,
    ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
        Ok(())
    }
}

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct CreateInviteCodes<'a> {
    ///Defaults to `1`.
    #[serde(default = "_default_create_invite_codes_code_count")]
    pub code_count: i64,
    #[serde(skip_serializing_if = "std::option::Option::is_none")]
    #[serde(borrow)]
    pub for_accounts: std::option::Option<Vec<jacquard_common::types::string::Did<'a>>>,
    pub use_count: i64,
}

fn _default_create_invite_codes_code_count() -> i64 {
    1i64
}

pub mod create_invite_codes_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CodeCount;
        type UseCount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CodeCount = Unset;
        type UseCount = Unset;
    }
    ///State transition - sets the `code_count` field to Set
    pub struct SetCodeCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCodeCount<S> {}
    impl<S: State> State for SetCodeCount<S> {
        type CodeCount = Set<members::code_count>;
        type UseCount = S::UseCount;
    }
    ///State transition - sets the `use_count` field to Set
    pub struct SetUseCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUseCount<S> {}
    impl<S: State> State for SetUseCount<S> {
        type CodeCount = S::CodeCount;
        type UseCount = Set<members::use_count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `code_count` field
        pub struct code_count(());
        ///Marker type for the `use_count` field
        pub struct use_count(());
    }
}

/// Builder for constructing an instance of this type
pub struct CreateInviteCodesBuilder<'a, S: create_invite_codes_state::State> {
    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
    __unsafe_private_named: (
        ::core::option::Option<i64>,
        ::core::option::Option<Vec<jacquard_common::types::string::Did<'a>>>,
        ::core::option::Option<i64>,
    ),
    _phantom: ::core::marker::PhantomData<&'a ()>,
}

impl<'a> CreateInviteCodes<'a> {
    /// Create a new builder for this type
    pub fn new() -> CreateInviteCodesBuilder<'a, create_invite_codes_state::Empty> {
        CreateInviteCodesBuilder::new()
    }
}

impl<'a> CreateInviteCodesBuilder<'a, create_invite_codes_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        CreateInviteCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: (None, None, None),
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> CreateInviteCodesBuilder<'a, S>
where
    S: create_invite_codes_state::State,
    S::CodeCount: create_invite_codes_state::IsUnset,
{
    /// Set the `codeCount` field (required)
    pub fn code_count(
        mut self,
        value: impl Into<i64>,
    ) -> CreateInviteCodesBuilder<'a, create_invite_codes_state::SetCodeCount<S>> {
        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
        CreateInviteCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S: create_invite_codes_state::State> CreateInviteCodesBuilder<'a, S> {
    /// Set the `forAccounts` field (optional)
    pub fn for_accounts(
        mut self,
        value: impl Into<Option<Vec<jacquard_common::types::string::Did<'a>>>>,
    ) -> Self {
        self.__unsafe_private_named.1 = value.into();
        self
    }
    /// Set the `forAccounts` field to an Option value (optional)
    pub fn maybe_for_accounts(
        mut self,
        value: Option<Vec<jacquard_common::types::string::Did<'a>>>,
    ) -> Self {
        self.__unsafe_private_named.1 = value;
        self
    }
}

impl<'a, S> CreateInviteCodesBuilder<'a, S>
where
    S: create_invite_codes_state::State,
    S::UseCount: create_invite_codes_state::IsUnset,
{
    /// Set the `useCount` field (required)
    pub fn use_count(
        mut self,
        value: impl Into<i64>,
    ) -> CreateInviteCodesBuilder<'a, create_invite_codes_state::SetUseCount<S>> {
        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
        CreateInviteCodesBuilder {
            _phantom_state: ::core::marker::PhantomData,
            __unsafe_private_named: self.__unsafe_private_named,
            _phantom: ::core::marker::PhantomData,
        }
    }
}

impl<'a, S> CreateInviteCodesBuilder<'a, S>
where
    S: create_invite_codes_state::State,
    S::CodeCount: create_invite_codes_state::IsSet,
    S::UseCount: create_invite_codes_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CreateInviteCodes<'a> {
        CreateInviteCodes {
            code_count: self.__unsafe_private_named.0.unwrap(),
            for_accounts: self.__unsafe_private_named.1,
            use_count: self.__unsafe_private_named.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: std::collections::BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> CreateInviteCodes<'a> {
        CreateInviteCodes {
            code_count: self.__unsafe_private_named.0.unwrap(),
            for_accounts: self.__unsafe_private_named.1,
            use_count: self.__unsafe_private_named.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

#[jacquard_derive::lexicon]
#[derive(
    serde::Serialize,
    serde::Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct CreateInviteCodesOutput<'a> {
    #[serde(borrow)]
    pub codes: Vec<crate::com_atproto::server::create_invite_codes::AccountCodes<'a>>,
}

/// Response type for
///com.atproto.server.createInviteCodes
pub struct CreateInviteCodesResponse;
impl jacquard_common::xrpc::XrpcResp for CreateInviteCodesResponse {
    const NSID: &'static str = "com.atproto.server.createInviteCodes";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = CreateInviteCodesOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for CreateInviteCodes<'a> {
    const NSID: &'static str = "com.atproto.server.createInviteCodes";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Response = CreateInviteCodesResponse;
}

/// Endpoint type for
///com.atproto.server.createInviteCodes
pub struct CreateInviteCodesRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CreateInviteCodesRequest {
    const PATH: &'static str = "/xrpc/com.atproto.server.createInviteCodes";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
        "application/json",
    );
    type Request<'de> = CreateInviteCodes<'de>;
    type Response = CreateInviteCodesResponse;
}