jacquard-api 0.12.0-beta.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
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
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: org.okazu-diary.material.external
//
// 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::{BosStr, CowStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

use crate::com_atproto::label::SelfLabels;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::org_okazu_diary::material::Tag;
use crate::org_okazu_diary::material::external;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
/// A descriptor of a pornographic material.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "org.okazu-diary.material.external",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct External<S: BosStr = DefaultStr> {
    ///Description of the material, typically taken from the material's HTML metadata.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///General-purpose self-label values primarily for consumption by generic AT clients who may not expect the sensitive nature of this Lexicon. Publishers of this record are strongly recommended to always include at least one of the protocol-global label values; namely, `porn`, `sexual`, `graphic-media`, and `nudity`, unless the material and tags are all known to be safe by themselves. It is the safest to unconditionally include the `sexual` value, which has the `adultOnly` semantics, but it is acceptable to use a stronger (`porn`/`graphic-media`) or more moderate (`nudity`) value instead if the user decides so.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub generic_labels: Option<SelfLabels<S>>,
    ///User-specified self-label values for the material. While the Lexicon by its nature assumes the material to be possibly sensitive by default, these label values are intended to signal that a warning should be put on the material even for the explicit Okazu-Diary.org application users who are willing to see mature contents in general.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<SelfLabels<S>>,
    ///Reference to a record representing the material, such as a Bluesky post.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub record: Option<StrongRef<S>>,
    ///User-specified tags for the material.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<Tag<S>>>,
    ///Link to a thumbnail of the material, typically taken from the material's HTML metadata.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumb: Option<external::Thumb<S>>,
    ///Title of the material, typically taken from the material's HTML `<title>` element.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<S>,
    ///URI of the material, typically an HTTP(S) URL. If the URL is of a Web interface for an AT resource (such as a `bsky.app` URL), the record should also include the `record` property referencing the AT resource.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uri: Option<UriValue<S>>,
    ///Reference to an `org.okazu-diary.feed.material` record from another repository from which this collection item is derived. Clients can use this property to offer the user to update this record if the original record have updated from the referenced version.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub via: Option<StrongRef<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ExternalGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: External<S>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Thumb<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub url: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> External<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, ExternalRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct ExternalRecord;
impl XrpcResp for ExternalRecord {
    const NSID: &'static str = "org.okazu-diary.material.external";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ExternalGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<ExternalGetRecordOutput<S>> for External<S> {
    fn from(output: ExternalGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for External<S> {
    const NSID: &'static str = "org.okazu-diary.material.external";
    type Record = ExternalRecord;
}

impl Collection for ExternalRecord {
    const NSID: &'static str = "org.okazu-diary.material.external";
    type Record = ExternalRecord;
}

impl<S: BosStr> LexiconSchema for External<S> {
    fn nsid() -> &'static str {
        "org.okazu-diary.material.external"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_okazu_diary_material_external()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.tags {
            #[allow(unused_comparisons)]
            if value.len() > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tags"),
                    max: 64usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Thumb<S> {
    fn nsid() -> &'static str {
        "org.okazu-diary.material.external"
    }
    fn def_name() -> &'static str {
        "thumb"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_okazu_diary_material_external()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod external_state {

    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
    #[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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

/// Builder for constructing an instance of this type.
pub struct ExternalBuilder<S: BosStr, St: external_state::State> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<SelfLabels<S>>,
        Option<SelfLabels<S>>,
        Option<StrongRef<S>>,
        Option<Vec<Tag<S>>>,
        Option<external::Thumb<S>>,
        Option<S>,
        Option<UriValue<S>>,
        Option<StrongRef<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl<S: BosStr> External<S> {
    /// Create a new builder for this type.
    pub fn new() -> ExternalBuilder<S, external_state::Empty> {
        ExternalBuilder::new()
    }
}

impl<S: BosStr> ExternalBuilder<S, external_state::Empty> {
    /// Create a new builder with all fields unset.
    pub fn new() -> Self {
        ExternalBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `description` field (optional)
    pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `description` field to an Option value (optional)
    pub fn maybe_description(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `genericLabels` field (optional)
    pub fn generic_labels(mut self, value: impl Into<Option<SelfLabels<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `genericLabels` field to an Option value (optional)
    pub fn maybe_generic_labels(mut self, value: Option<SelfLabels<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<SelfLabels<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<SelfLabels<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `record` field (optional)
    pub fn record(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `record` field to an Option value (optional)
    pub fn maybe_record(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `tags` field (optional)
    pub fn tags(mut self, value: impl Into<Option<Vec<Tag<S>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `tags` field to an Option value (optional)
    pub fn maybe_tags(mut self, value: Option<Vec<Tag<S>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `thumb` field (optional)
    pub fn thumb(mut self, value: impl Into<Option<external::Thumb<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `thumb` field to an Option value (optional)
    pub fn maybe_thumb(mut self, value: Option<external::Thumb<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `title` field (optional)
    pub fn title(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `title` field to an Option value (optional)
    pub fn maybe_title(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `uri` field (optional)
    pub fn uri(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `uri` field to an Option value (optional)
    pub fn maybe_uri(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<S: BosStr, St: external_state::State> ExternalBuilder<S, St> {
    /// Set the `via` field (optional)
    pub fn via(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `via` field to an Option value (optional)
    pub fn maybe_via(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<S: BosStr, St> ExternalBuilder<S, St>
where
    St: external_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> External<S> {
        External {
            description: self._fields.0,
            generic_labels: self._fields.1,
            labels: self._fields.2,
            record: self._fields.3,
            tags: self._fields.4,
            thumb: self._fields.5,
            title: self._fields.6,
            uri: self._fields.7,
            via: self._fields.8,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> External<S> {
        External {
            description: self._fields.0,
            generic_labels: self._fields.1,
            labels: self._fields.2,
            record: self._fields.3,
            tags: self._fields.4,
            thumb: self._fields.5,
            title: self._fields.6,
            uri: self._fields.7,
            via: self._fields.8,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_okazu_diary_material_external() -> LexiconDoc<'static> {
    use alloc::collections::BTreeMap;
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("org.okazu-diary.material.external"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static("A descriptor of a pornographic material."),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Description of the material, typically taken from the material's HTML metadata.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("genericLabels"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "General-purpose self-label values primarily for consumption by generic AT clients who may not expect the sensitive nature of this Lexicon. Publishers of this record are strongly recommended to always include at least one of the protocol-global label values; namely, `porn`, `sexual`, `graphic-media`, and `nudity`, unless the material and tags are all known to be safe by themselves. It is the safest to unconditionally include the `sexual` value, which has the `adultOnly` semantics, but it is acceptable to use a stronger (`porn`/`graphic-media`) or more moderate (`nudity`) value instead if the user decides so.",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("com.atproto.label.defs#selfLabels")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("labels"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "User-specified self-label values for the material. While the Lexicon by its nature assumes the material to be possibly sensitive by default, these label values are intended to signal that a warning should be put on the material even for the explicit Okazu-Diary.org application users who are willing to see mature contents in general.",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("com.atproto.label.defs#selfLabels")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("record"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("tags"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static("User-specified tags for the material."),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static(
                                            "org.okazu-diary.material.defs#tag",
                                        ),
                                        ..Default::default()
                                    }),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("thumb"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#thumb"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Title of the material, typically taken from the material's HTML `<title>` element.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("uri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the material, typically an HTTP(S) URL. If the URL is of a Web interface for an AT resource (such as a `bsky.app` URL), the record should also include the `record` property referencing the AT resource.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("via"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("thumb"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("url")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod thumb_state {

    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
    #[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 Url;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Url = Unset;
    }
    ///State transition - sets the `url` field to Set
    pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUrl<St> {}
    impl<St: State> State for SetUrl<St> {
        type Url = Set<members::url>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `url` field
        pub struct url(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ThumbBuilder<S: BosStr, St: thumb_state::State> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Cid<S>>, Option<UriValue<S>>),
    _type: PhantomData<fn() -> S>,
}

impl<S: BosStr> Thumb<S> {
    /// Create a new builder for this type.
    pub fn new() -> ThumbBuilder<S, thumb_state::Empty> {
        ThumbBuilder::new()
    }
}

impl<S: BosStr> ThumbBuilder<S, thumb_state::Empty> {
    /// Create a new builder with all fields unset.
    pub fn new() -> Self {
        ThumbBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St: thumb_state::State> ThumbBuilder<S, St> {
    /// Set the `cid` field (optional)
    pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cid` field to an Option value (optional)
    pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<S: BosStr, St> ThumbBuilder<S, St>
where
    St: thumb_state::State,
    St::Url: thumb_state::IsUnset,
{
    /// Set the `url` field (required)
    pub fn url(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> ThumbBuilder<S, thumb_state::SetUrl<St>> {
        self._fields.1 = Option::Some(value.into());
        ThumbBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> ThumbBuilder<S, St>
where
    St: thumb_state::State,
    St::Url: thumb_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Thumb<S> {
        Thumb {
            cid: self._fields.0,
            url: 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<SmolStr, Data<S>>) -> Thumb<S> {
        Thumb {
            cid: self._fields.0,
            url: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}