jacquard-api 0.11.0

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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.atproto.temp.checkHandleAvailability
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Handle, Datetime};
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::temp::check_handle_availability;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CheckHandleAvailability<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub birth_date: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub email: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub handle: Handle<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CheckHandleAvailabilityOutput<'a> {
    ///Echo of the input handle.
    #[serde(borrow)]
    pub handle: Handle<'a>,
    #[serde(borrow)]
    pub result: CheckHandleAvailabilityOutputResult<'a>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum CheckHandleAvailabilityOutputResult<'a> {
    #[serde(rename = "com.atproto.temp.checkHandleAvailability#resultAvailable")]
    ResultAvailable(Box<check_handle_availability::ResultAvailable<'a>>),
    #[serde(rename = "com.atproto.temp.checkHandleAvailability#resultUnavailable")]
    ResultUnavailable(Box<check_handle_availability::ResultUnavailable<'a>>),
}


#[open_union]
#[derive(
    Serialize,
    Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    thiserror::Error,
    miette::Diagnostic,
    IntoStatic
)]

#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum CheckHandleAvailabilityError<'a> {
    /// An invalid email was provided.
    #[serde(rename = "InvalidEmail")]
    InvalidEmail(Option<CowStr<'a>>),
}

impl core::fmt::Display for CheckHandleAvailabilityError<'_> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::InvalidEmail(msg) => {
                write!(f, "InvalidEmail")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
        }
    }
}

/// Indicates the provided handle is available.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ResultAvailable<'a> {}
/// Indicates the provided handle is unavailable and gives suggestions of available handles.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ResultUnavailable<'a> {
    ///List of suggested handles based on the provided inputs.
    #[serde(borrow)]
    pub suggestions: Vec<check_handle_availability::Suggestion<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Suggestion<'a> {
    #[serde(borrow)]
    pub handle: Handle<'a>,
    ///Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics.
    #[serde(borrow)]
    pub method: CowStr<'a>,
}

/// Response type for com.atproto.temp.checkHandleAvailability
pub struct CheckHandleAvailabilityResponse;
impl jacquard_common::xrpc::XrpcResp for CheckHandleAvailabilityResponse {
    const NSID: &'static str = "com.atproto.temp.checkHandleAvailability";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = CheckHandleAvailabilityOutput<'de>;
    type Err<'de> = CheckHandleAvailabilityError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for CheckHandleAvailability<'a> {
    const NSID: &'static str = "com.atproto.temp.checkHandleAvailability";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = CheckHandleAvailabilityResponse;
}

/// Endpoint type for com.atproto.temp.checkHandleAvailability
pub struct CheckHandleAvailabilityRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CheckHandleAvailabilityRequest {
    const PATH: &'static str = "/xrpc/com.atproto.temp.checkHandleAvailability";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = CheckHandleAvailability<'de>;
    type Response = CheckHandleAvailabilityResponse;
}

impl<'a> LexiconSchema for ResultAvailable<'a> {
    fn nsid() -> &'static str {
        "com.atproto.temp.checkHandleAvailability"
    }
    fn def_name() -> &'static str {
        "resultAvailable"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_temp_checkHandleAvailability()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for ResultUnavailable<'a> {
    fn nsid() -> &'static str {
        "com.atproto.temp.checkHandleAvailability"
    }
    fn def_name() -> &'static str {
        "resultUnavailable"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_temp_checkHandleAvailability()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Suggestion<'a> {
    fn nsid() -> &'static str {
        "com.atproto.temp.checkHandleAvailability"
    }
    fn def_name() -> &'static str {
        "suggestion"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_temp_checkHandleAvailability()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod check_handle_availability_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 Handle;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Handle = Unset;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHandle<S> {}
    impl<S: State> State for SetHandle<S> {
        type Handle = Set<members::handle>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `handle` field
        pub struct handle(());
    }
}

/// Builder for constructing an instance of this type
pub struct CheckHandleAvailabilityBuilder<
    'a,
    S: check_handle_availability_state::State,
> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Datetime>, Option<CowStr<'a>>, Option<Handle<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> CheckHandleAvailability<'a> {
    /// Create a new builder for this type
    pub fn new() -> CheckHandleAvailabilityBuilder<
        'a,
        check_handle_availability_state::Empty,
    > {
        CheckHandleAvailabilityBuilder::new()
    }
}

impl<'a> CheckHandleAvailabilityBuilder<'a, check_handle_availability_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        CheckHandleAvailabilityBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<
    'a,
    S: check_handle_availability_state::State,
> CheckHandleAvailabilityBuilder<'a, S> {
    /// Set the `birthDate` field (optional)
    pub fn birth_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `birthDate` field to an Option value (optional)
    pub fn maybe_birth_date(mut self, value: Option<Datetime>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<
    'a,
    S: check_handle_availability_state::State,
> CheckHandleAvailabilityBuilder<'a, S> {
    /// Set the `email` field (optional)
    pub fn email(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `email` field to an Option value (optional)
    pub fn maybe_email(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> CheckHandleAvailabilityBuilder<'a, S>
where
    S: check_handle_availability_state::State,
    S::Handle: check_handle_availability_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<Handle<'a>>,
    ) -> CheckHandleAvailabilityBuilder<
        'a,
        check_handle_availability_state::SetHandle<S>,
    > {
        self._fields.2 = Option::Some(value.into());
        CheckHandleAvailabilityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CheckHandleAvailabilityBuilder<'a, S>
where
    S: check_handle_availability_state::State,
    S::Handle: check_handle_availability_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CheckHandleAvailability<'a> {
        CheckHandleAvailability {
            birth_date: self._fields.0,
            email: self._fields.1,
            handle: self._fields.2.unwrap(),
        }
    }
}

fn lexicon_doc_com_atproto_temp_checkHandleAvailability() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("com.atproto.temp.checkHandleAvailability"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("handle")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("birthDate"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "User-provided birth date. Might be used to build handle suggestions.",
                                            ),
                                        ),
                                        format: Some(LexStringFormat::Datetime),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("email"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "User-provided email. Might be used to build handle suggestions.",
                                            ),
                                        ),
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("handle"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static(
                                                "Tentative handle. Will be checked for availability or used to build handle suggestions.",
                                            ),
                                        ),
                                        format: Some(LexStringFormat::Handle),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("resultAvailable"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Indicates the provided handle is available."),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("resultUnavailable"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Indicates the provided handle is unavailable and gives suggestions of available handles.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("suggestions")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("suggestions"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of suggested handles based on the provided inputs.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#suggestion"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("suggestion"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("handle"), SmolStr::new_static("method")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Handle),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("method"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Method used to build this suggestion. Should be considered opaque to clients. Can be used for metrics.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod result_unavailable_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 Suggestions;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Suggestions = Unset;
    }
    ///State transition - sets the `suggestions` field to Set
    pub struct SetSuggestions<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSuggestions<S> {}
    impl<S: State> State for SetSuggestions<S> {
        type Suggestions = Set<members::suggestions>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `suggestions` field
        pub struct suggestions(());
    }
}

/// Builder for constructing an instance of this type
pub struct ResultUnavailableBuilder<'a, S: result_unavailable_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<check_handle_availability::Suggestion<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ResultUnavailable<'a> {
    /// Create a new builder for this type
    pub fn new() -> ResultUnavailableBuilder<'a, result_unavailable_state::Empty> {
        ResultUnavailableBuilder::new()
    }
}

impl<'a> ResultUnavailableBuilder<'a, result_unavailable_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        ResultUnavailableBuilder {
            _state: PhantomData,
            _fields: (None,),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ResultUnavailableBuilder<'a, S>
where
    S: result_unavailable_state::State,
    S::Suggestions: result_unavailable_state::IsUnset,
{
    /// Set the `suggestions` field (required)
    pub fn suggestions(
        mut self,
        value: impl Into<Vec<check_handle_availability::Suggestion<'a>>>,
    ) -> ResultUnavailableBuilder<'a, result_unavailable_state::SetSuggestions<S>> {
        self._fields.0 = Option::Some(value.into());
        ResultUnavailableBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ResultUnavailableBuilder<'a, S>
where
    S: result_unavailable_state::State,
    S::Suggestions: result_unavailable_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ResultUnavailable<'a> {
        ResultUnavailable {
            suggestions: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ResultUnavailable<'a> {
        ResultUnavailable {
            suggestions: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod suggestion_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 Method;
        type Handle;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Method = Unset;
        type Handle = Unset;
    }
    ///State transition - sets the `method` field to Set
    pub struct SetMethod<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMethod<S> {}
    impl<S: State> State for SetMethod<S> {
        type Method = Set<members::method>;
        type Handle = S::Handle;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHandle<S> {}
    impl<S: State> State for SetHandle<S> {
        type Method = S::Method;
        type Handle = Set<members::handle>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `method` field
        pub struct method(());
        ///Marker type for the `handle` field
        pub struct handle(());
    }
}

/// Builder for constructing an instance of this type
pub struct SuggestionBuilder<'a, S: suggestion_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Handle<'a>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Suggestion<'a> {
    /// Create a new builder for this type
    pub fn new() -> SuggestionBuilder<'a, suggestion_state::Empty> {
        SuggestionBuilder::new()
    }
}

impl<'a> SuggestionBuilder<'a, suggestion_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SuggestionBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SuggestionBuilder<'a, S>
where
    S: suggestion_state::State,
    S::Handle: suggestion_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<Handle<'a>>,
    ) -> SuggestionBuilder<'a, suggestion_state::SetHandle<S>> {
        self._fields.0 = Option::Some(value.into());
        SuggestionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SuggestionBuilder<'a, S>
where
    S: suggestion_state::State,
    S::Method: suggestion_state::IsUnset,
{
    /// Set the `method` field (required)
    pub fn method(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SuggestionBuilder<'a, suggestion_state::SetMethod<S>> {
        self._fields.1 = Option::Some(value.into());
        SuggestionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SuggestionBuilder<'a, S>
where
    S: suggestion_state::State,
    S::Method: suggestion_state::IsSet,
    S::Handle: suggestion_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Suggestion<'a> {
        Suggestion {
            handle: self._fields.0.unwrap(),
            method: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Suggestion<'a> {
        Suggestion {
            handle: self._fields.0.unwrap(),
            method: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}