Skip to main content

jacquard_api/com_atproto/
label.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.label.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8//! Generated bindings for the `com.atproto.label` Lexicon namespace/module.
9pub mod query_labels;
10
11
12#[cfg(feature = "streaming")]
13pub mod subscribe_labels;
14
15
16#[allow(unused_imports)]
17use alloc::collections::BTreeMap;
18
19#[allow(unused_imports)]
20use core::marker::PhantomData;
21use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
22use jacquard_common::deps::bytes::Bytes;
23
24#[allow(unused_imports)]
25use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
26use jacquard_common::deps::smol_str::SmolStr;
27use jacquard_common::types::string::{Did, Cid, Datetime, Language, UriValue};
28use jacquard_common::types::value::Data;
29use jacquard_derive::IntoStatic;
30use jacquard_lexicon::lexicon::LexiconDoc;
31use jacquard_lexicon::schema::LexiconSchema;
32
33#[allow(unused_imports)]
34use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
35use serde::{Serialize, Deserialize};
36use crate::com_atproto::label;
37/// Metadata tag on an atproto resource (eg, repo or record).
38
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
41pub struct Label<S: BosStr = DefaultStr> {
42    ///Optionally, CID specifying the specific version of 'uri' resource this label applies to.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub cid: Option<Cid<S>>,
45    ///Timestamp when this label was created.
46    pub cts: Datetime,
47    ///Timestamp at which this label expires (no longer applies).
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub exp: Option<Datetime>,
50    ///If true, this is a negation label, overwriting a previous label.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub neg: Option<bool>,
53    ///Signature of dag-cbor encoded label.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
56    pub sig: Option<Bytes>,
57    ///DID of the actor who created this label.
58    pub src: Did<S>,
59    ///AT URI of the record, repository (account), or other resource that this label applies to.
60    pub uri: UriValue<S>,
61    ///The short string name of the value or type of this label.
62    pub val: S,
63    ///The AT Protocol version of the label object.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub ver: Option<i64>,
66    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
67    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
68}
69
70
71#[derive(Debug, Clone, PartialEq, Eq, Hash)]
72pub enum LabelValue<S: BosStr = DefaultStr> {
73    Hide,
74    Warn,
75    NoUnauthenticated,
76    Porn,
77    Sexual,
78    Nudity,
79    GraphicMedia,
80    Bot,
81    Other(S),
82}
83
84impl<S: BosStr> LabelValue<S> {
85    pub fn as_str(&self) -> &str {
86        match self {
87            Self::Hide => "!hide",
88            Self::Warn => "!warn",
89            Self::NoUnauthenticated => "!no-unauthenticated",
90            Self::Porn => "porn",
91            Self::Sexual => "sexual",
92            Self::Nudity => "nudity",
93            Self::GraphicMedia => "graphic-media",
94            Self::Bot => "bot",
95            Self::Other(s) => s.as_ref(),
96        }
97    }
98    /// Construct from a string-like value, matching known values.
99    pub fn from_value(s: S) -> Self {
100        match s.as_ref() {
101            "!hide" => Self::Hide,
102            "!warn" => Self::Warn,
103            "!no-unauthenticated" => Self::NoUnauthenticated,
104            "porn" => Self::Porn,
105            "sexual" => Self::Sexual,
106            "nudity" => Self::Nudity,
107            "graphic-media" => Self::GraphicMedia,
108            "bot" => Self::Bot,
109            _ => Self::Other(s),
110        }
111    }
112}
113
114impl<S: BosStr> AsRef<str> for LabelValue<S> {
115    fn as_ref(&self) -> &str {
116        self.as_str()
117    }
118}
119
120impl<S: BosStr> core::fmt::Display for LabelValue<S> {
121    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
122        write!(f, "{}", self.as_str())
123    }
124}
125
126impl<S: BosStr> Serialize for LabelValue<S> {
127    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
128    where
129        Ser: serde::Serializer,
130    {
131        serializer.serialize_str(self.as_str())
132    }
133}
134
135impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for LabelValue<S> {
136    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
137    where
138        D: serde::Deserializer<'de>,
139    {
140        let s = S::deserialize(deserializer)?;
141        Ok(Self::from_value(s))
142    }
143}
144
145impl<S: BosStr> jacquard_common::IntoStatic for LabelValue<S>
146where
147    S: BosStr + jacquard_common::IntoStatic,
148    S::Output: BosStr,
149{
150    type Output = LabelValue<S::Output>;
151    fn into_static(self) -> Self::Output {
152        match self {
153            LabelValue::Hide => LabelValue::Hide,
154            LabelValue::Warn => LabelValue::Warn,
155            LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
156            LabelValue::Porn => LabelValue::Porn,
157            LabelValue::Sexual => LabelValue::Sexual,
158            LabelValue::Nudity => LabelValue::Nudity,
159            LabelValue::GraphicMedia => LabelValue::GraphicMedia,
160            LabelValue::Bot => LabelValue::Bot,
161            LabelValue::Other(v) => LabelValue::Other(v.into_static()),
162        }
163    }
164}
165
166/// Declares a label value and its expected interpretations and behaviors.
167
168#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
169#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
170pub struct LabelValueDefinition<S: BosStr = DefaultStr> {
171    ///Does the user need to have adult content enabled in order to configure this label?
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub adult_only: Option<bool>,
174    ///What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
175    pub blurs: LabelValueDefinitionBlurs<S>,
176    ///The default setting for this label.
177    #[serde(skip_serializing_if = "Option::is_none")]
178    pub default_setting: Option<LabelValueDefinitionDefaultSetting<S>>,
179    ///The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
180    pub identifier: S,
181    pub locales: Vec<label::LabelValueDefinitionStrings<S>>,
182    ///How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
183    pub severity: LabelValueDefinitionSeverity<S>,
184    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
185    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
186}
187
188/// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
189
190#[derive(Debug, Clone, PartialEq, Eq, Hash)]
191pub enum LabelValueDefinitionBlurs<S: BosStr = DefaultStr> {
192    Content,
193    Media,
194    None,
195    Other(S),
196}
197
198impl<S: BosStr> LabelValueDefinitionBlurs<S> {
199    pub fn as_str(&self) -> &str {
200        match self {
201            Self::Content => "content",
202            Self::Media => "media",
203            Self::None => "none",
204            Self::Other(s) => s.as_ref(),
205        }
206    }
207    /// Construct from a string-like value, matching known values.
208    pub fn from_value(s: S) -> Self {
209        match s.as_ref() {
210            "content" => Self::Content,
211            "media" => Self::Media,
212            "none" => Self::None,
213            _ => Self::Other(s),
214        }
215    }
216}
217
218impl<S: BosStr> core::fmt::Display for LabelValueDefinitionBlurs<S> {
219    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
220        write!(f, "{}", self.as_str())
221    }
222}
223
224impl<S: BosStr> AsRef<str> for LabelValueDefinitionBlurs<S> {
225    fn as_ref(&self) -> &str {
226        self.as_str()
227    }
228}
229
230impl<S: BosStr> Serialize for LabelValueDefinitionBlurs<S> {
231    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
232    where
233        Ser: serde::Serializer,
234    {
235        serializer.serialize_str(self.as_str())
236    }
237}
238
239impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
240for LabelValueDefinitionBlurs<S> {
241    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
242    where
243        D: serde::Deserializer<'de>,
244    {
245        let s = S::deserialize(deserializer)?;
246        Ok(Self::from_value(s))
247    }
248}
249
250impl<S: BosStr + Default> Default for LabelValueDefinitionBlurs<S> {
251    fn default() -> Self {
252        Self::Other(Default::default())
253    }
254}
255
256impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionBlurs<S>
257where
258    S: BosStr + jacquard_common::IntoStatic,
259    S::Output: BosStr,
260{
261    type Output = LabelValueDefinitionBlurs<S::Output>;
262    fn into_static(self) -> Self::Output {
263        match self {
264            LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content,
265            LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media,
266            LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None,
267            LabelValueDefinitionBlurs::Other(v) => {
268                LabelValueDefinitionBlurs::Other(v.into_static())
269            }
270        }
271    }
272}
273
274/// The default setting for this label.
275
276#[derive(Debug, Clone, PartialEq, Eq, Hash)]
277pub enum LabelValueDefinitionDefaultSetting<S: BosStr = DefaultStr> {
278    Ignore,
279    Warn,
280    Hide,
281    Other(S),
282}
283
284impl<S: BosStr> LabelValueDefinitionDefaultSetting<S> {
285    pub fn as_str(&self) -> &str {
286        match self {
287            Self::Ignore => "ignore",
288            Self::Warn => "warn",
289            Self::Hide => "hide",
290            Self::Other(s) => s.as_ref(),
291        }
292    }
293    /// Construct from a string-like value, matching known values.
294    pub fn from_value(s: S) -> Self {
295        match s.as_ref() {
296            "ignore" => Self::Ignore,
297            "warn" => Self::Warn,
298            "hide" => Self::Hide,
299            _ => Self::Other(s),
300        }
301    }
302}
303
304impl<S: BosStr> core::fmt::Display for LabelValueDefinitionDefaultSetting<S> {
305    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
306        write!(f, "{}", self.as_str())
307    }
308}
309
310impl<S: BosStr> AsRef<str> for LabelValueDefinitionDefaultSetting<S> {
311    fn as_ref(&self) -> &str {
312        self.as_str()
313    }
314}
315
316impl<S: BosStr> Serialize for LabelValueDefinitionDefaultSetting<S> {
317    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
318    where
319        Ser: serde::Serializer,
320    {
321        serializer.serialize_str(self.as_str())
322    }
323}
324
325impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
326for LabelValueDefinitionDefaultSetting<S> {
327    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
328    where
329        D: serde::Deserializer<'de>,
330    {
331        let s = S::deserialize(deserializer)?;
332        Ok(Self::from_value(s))
333    }
334}
335
336impl<S: BosStr + Default> Default for LabelValueDefinitionDefaultSetting<S> {
337    fn default() -> Self {
338        Self::Other(Default::default())
339    }
340}
341
342impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<S>
343where
344    S: BosStr + jacquard_common::IntoStatic,
345    S::Output: BosStr,
346{
347    type Output = LabelValueDefinitionDefaultSetting<S::Output>;
348    fn into_static(self) -> Self::Output {
349        match self {
350            LabelValueDefinitionDefaultSetting::Ignore => {
351                LabelValueDefinitionDefaultSetting::Ignore
352            }
353            LabelValueDefinitionDefaultSetting::Warn => {
354                LabelValueDefinitionDefaultSetting::Warn
355            }
356            LabelValueDefinitionDefaultSetting::Hide => {
357                LabelValueDefinitionDefaultSetting::Hide
358            }
359            LabelValueDefinitionDefaultSetting::Other(v) => {
360                LabelValueDefinitionDefaultSetting::Other(v.into_static())
361            }
362        }
363    }
364}
365
366/// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
367
368#[derive(Debug, Clone, PartialEq, Eq, Hash)]
369pub enum LabelValueDefinitionSeverity<S: BosStr = DefaultStr> {
370    Inform,
371    Alert,
372    None,
373    Other(S),
374}
375
376impl<S: BosStr> LabelValueDefinitionSeverity<S> {
377    pub fn as_str(&self) -> &str {
378        match self {
379            Self::Inform => "inform",
380            Self::Alert => "alert",
381            Self::None => "none",
382            Self::Other(s) => s.as_ref(),
383        }
384    }
385    /// Construct from a string-like value, matching known values.
386    pub fn from_value(s: S) -> Self {
387        match s.as_ref() {
388            "inform" => Self::Inform,
389            "alert" => Self::Alert,
390            "none" => Self::None,
391            _ => Self::Other(s),
392        }
393    }
394}
395
396impl<S: BosStr> core::fmt::Display for LabelValueDefinitionSeverity<S> {
397    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
398        write!(f, "{}", self.as_str())
399    }
400}
401
402impl<S: BosStr> AsRef<str> for LabelValueDefinitionSeverity<S> {
403    fn as_ref(&self) -> &str {
404        self.as_str()
405    }
406}
407
408impl<S: BosStr> Serialize for LabelValueDefinitionSeverity<S> {
409    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
410    where
411        Ser: serde::Serializer,
412    {
413        serializer.serialize_str(self.as_str())
414    }
415}
416
417impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
418for LabelValueDefinitionSeverity<S> {
419    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
420    where
421        D: serde::Deserializer<'de>,
422    {
423        let s = S::deserialize(deserializer)?;
424        Ok(Self::from_value(s))
425    }
426}
427
428impl<S: BosStr + Default> Default for LabelValueDefinitionSeverity<S> {
429    fn default() -> Self {
430        Self::Other(Default::default())
431    }
432}
433
434impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionSeverity<S>
435where
436    S: BosStr + jacquard_common::IntoStatic,
437    S::Output: BosStr,
438{
439    type Output = LabelValueDefinitionSeverity<S::Output>;
440    fn into_static(self) -> Self::Output {
441        match self {
442            LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform,
443            LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert,
444            LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None,
445            LabelValueDefinitionSeverity::Other(v) => {
446                LabelValueDefinitionSeverity::Other(v.into_static())
447            }
448        }
449    }
450}
451
452/// Strings which describe the label in the UI, localized into a specific language.
453
454#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
455#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
456pub struct LabelValueDefinitionStrings<S: BosStr = DefaultStr> {
457    ///A longer description of what the label means and why it might be applied.
458    pub description: S,
459    ///The code of the language these strings are written in.
460    pub lang: Language,
461    ///A short human-readable name for the label.
462    pub name: S,
463    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
464    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
465}
466
467/// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.
468
469#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
470#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
471pub struct SelfLabel<S: BosStr = DefaultStr> {
472    ///The short string name of the value or type of this label.
473    pub val: S,
474    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
475    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
476}
477
478/// Metadata tags on an atproto record, published by the author within the record.
479
480#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
481#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
482pub struct SelfLabels<S: BosStr = DefaultStr> {
483    pub values: Vec<label::SelfLabel<S>>,
484    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
485    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
486}
487
488impl<S: BosStr> LexiconSchema for Label<S> {
489    fn nsid() -> &'static str {
490        "com.atproto.label.defs"
491    }
492    fn def_name() -> &'static str {
493        "label"
494    }
495    fn lexicon_doc() -> LexiconDoc<'static> {
496        lexicon_doc_com_atproto_label_defs()
497    }
498    fn validate(&self) -> Result<(), ConstraintError> {
499        {
500            let value = &self.val;
501            #[allow(unused_comparisons)]
502            if <str>::len(value.as_ref()) > 128usize {
503                return Err(ConstraintError::MaxLength {
504                    path: ValidationPath::from_field("val"),
505                    max: 128usize,
506                    actual: <str>::len(value.as_ref()),
507                });
508            }
509        }
510        Ok(())
511    }
512}
513
514impl<S: BosStr> LexiconSchema for LabelValueDefinition<S> {
515    fn nsid() -> &'static str {
516        "com.atproto.label.defs"
517    }
518    fn def_name() -> &'static str {
519        "labelValueDefinition"
520    }
521    fn lexicon_doc() -> LexiconDoc<'static> {
522        lexicon_doc_com_atproto_label_defs()
523    }
524    fn validate(&self) -> Result<(), ConstraintError> {
525        {
526            let value = &self.identifier;
527            #[allow(unused_comparisons)]
528            if <str>::len(value.as_ref()) > 100usize {
529                return Err(ConstraintError::MaxLength {
530                    path: ValidationPath::from_field("identifier"),
531                    max: 100usize,
532                    actual: <str>::len(value.as_ref()),
533                });
534            }
535        }
536        {
537            let value = &self.identifier;
538            {
539                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
540                if count > 100usize {
541                    return Err(ConstraintError::MaxGraphemes {
542                        path: ValidationPath::from_field("identifier"),
543                        max: 100usize,
544                        actual: count,
545                    });
546                }
547            }
548        }
549        Ok(())
550    }
551}
552
553impl<S: BosStr> LexiconSchema for LabelValueDefinitionStrings<S> {
554    fn nsid() -> &'static str {
555        "com.atproto.label.defs"
556    }
557    fn def_name() -> &'static str {
558        "labelValueDefinitionStrings"
559    }
560    fn lexicon_doc() -> LexiconDoc<'static> {
561        lexicon_doc_com_atproto_label_defs()
562    }
563    fn validate(&self) -> Result<(), ConstraintError> {
564        {
565            let value = &self.description;
566            #[allow(unused_comparisons)]
567            if <str>::len(value.as_ref()) > 100000usize {
568                return Err(ConstraintError::MaxLength {
569                    path: ValidationPath::from_field("description"),
570                    max: 100000usize,
571                    actual: <str>::len(value.as_ref()),
572                });
573            }
574        }
575        {
576            let value = &self.description;
577            {
578                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
579                if count > 10000usize {
580                    return Err(ConstraintError::MaxGraphemes {
581                        path: ValidationPath::from_field("description"),
582                        max: 10000usize,
583                        actual: count,
584                    });
585                }
586            }
587        }
588        {
589            let value = &self.name;
590            #[allow(unused_comparisons)]
591            if <str>::len(value.as_ref()) > 640usize {
592                return Err(ConstraintError::MaxLength {
593                    path: ValidationPath::from_field("name"),
594                    max: 640usize,
595                    actual: <str>::len(value.as_ref()),
596                });
597            }
598        }
599        {
600            let value = &self.name;
601            {
602                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
603                if count > 64usize {
604                    return Err(ConstraintError::MaxGraphemes {
605                        path: ValidationPath::from_field("name"),
606                        max: 64usize,
607                        actual: count,
608                    });
609                }
610            }
611        }
612        Ok(())
613    }
614}
615
616impl<S: BosStr> LexiconSchema for SelfLabel<S> {
617    fn nsid() -> &'static str {
618        "com.atproto.label.defs"
619    }
620    fn def_name() -> &'static str {
621        "selfLabel"
622    }
623    fn lexicon_doc() -> LexiconDoc<'static> {
624        lexicon_doc_com_atproto_label_defs()
625    }
626    fn validate(&self) -> Result<(), ConstraintError> {
627        {
628            let value = &self.val;
629            #[allow(unused_comparisons)]
630            if <str>::len(value.as_ref()) > 128usize {
631                return Err(ConstraintError::MaxLength {
632                    path: ValidationPath::from_field("val"),
633                    max: 128usize,
634                    actual: <str>::len(value.as_ref()),
635                });
636            }
637        }
638        Ok(())
639    }
640}
641
642impl<S: BosStr> LexiconSchema for SelfLabels<S> {
643    fn nsid() -> &'static str {
644        "com.atproto.label.defs"
645    }
646    fn def_name() -> &'static str {
647        "selfLabels"
648    }
649    fn lexicon_doc() -> LexiconDoc<'static> {
650        lexicon_doc_com_atproto_label_defs()
651    }
652    fn validate(&self) -> Result<(), ConstraintError> {
653        {
654            let value = &self.values;
655            #[allow(unused_comparisons)]
656            if value.len() > 10usize {
657                return Err(ConstraintError::MaxLength {
658                    path: ValidationPath::from_field("values"),
659                    max: 10usize,
660                    actual: value.len(),
661                });
662            }
663        }
664        Ok(())
665    }
666}
667
668pub mod label_state {
669
670    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
671    #[allow(unused)]
672    use ::core::marker::PhantomData;
673    mod sealed {
674        pub trait Sealed {}
675    }
676    /// State trait tracking which required fields have been set
677    pub trait State: sealed::Sealed {
678        type Cts;
679        type Src;
680        type Uri;
681        type Val;
682    }
683    /// Empty state - all required fields are unset
684    pub struct Empty(());
685    impl sealed::Sealed for Empty {}
686    impl State for Empty {
687        type Cts = Unset;
688        type Src = Unset;
689        type Uri = Unset;
690        type Val = Unset;
691    }
692    ///State transition - sets the `cts` field to Set
693    pub struct SetCts<St: State = Empty>(PhantomData<fn() -> St>);
694    impl<St: State> sealed::Sealed for SetCts<St> {}
695    impl<St: State> State for SetCts<St> {
696        type Cts = Set<members::cts>;
697        type Src = St::Src;
698        type Uri = St::Uri;
699        type Val = St::Val;
700    }
701    ///State transition - sets the `src` field to Set
702    pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>);
703    impl<St: State> sealed::Sealed for SetSrc<St> {}
704    impl<St: State> State for SetSrc<St> {
705        type Cts = St::Cts;
706        type Src = Set<members::src>;
707        type Uri = St::Uri;
708        type Val = St::Val;
709    }
710    ///State transition - sets the `uri` field to Set
711    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
712    impl<St: State> sealed::Sealed for SetUri<St> {}
713    impl<St: State> State for SetUri<St> {
714        type Cts = St::Cts;
715        type Src = St::Src;
716        type Uri = Set<members::uri>;
717        type Val = St::Val;
718    }
719    ///State transition - sets the `val` field to Set
720    pub struct SetVal<St: State = Empty>(PhantomData<fn() -> St>);
721    impl<St: State> sealed::Sealed for SetVal<St> {}
722    impl<St: State> State for SetVal<St> {
723        type Cts = St::Cts;
724        type Src = St::Src;
725        type Uri = St::Uri;
726        type Val = Set<members::val>;
727    }
728    /// Marker types for field names
729    #[allow(non_camel_case_types)]
730    pub mod members {
731        ///Marker type for the `cts` field
732        pub struct cts(());
733        ///Marker type for the `src` field
734        pub struct src(());
735        ///Marker type for the `uri` field
736        pub struct uri(());
737        ///Marker type for the `val` field
738        pub struct val(());
739    }
740}
741
742/// Builder for constructing an instance of this type.
743pub struct LabelBuilder<St: label_state::State, S: BosStr = DefaultStr> {
744    _state: PhantomData<fn() -> St>,
745    _fields: (
746        Option<Cid<S>>,
747        Option<Datetime>,
748        Option<Datetime>,
749        Option<bool>,
750        Option<Bytes>,
751        Option<Did<S>>,
752        Option<UriValue<S>>,
753        Option<S>,
754        Option<i64>,
755    ),
756    _type: PhantomData<fn() -> S>,
757}
758
759impl Label<DefaultStr> {
760    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
761    pub fn new() -> LabelBuilder<label_state::Empty, DefaultStr> {
762        LabelBuilder::new()
763    }
764}
765
766impl<S: BosStr> Label<S> {
767    /// Create a new builder for this type
768    pub fn builder() -> LabelBuilder<label_state::Empty, S> {
769        LabelBuilder::builder()
770    }
771}
772
773impl LabelBuilder<label_state::Empty, DefaultStr> {
774    /// Create a new builder with all fields unset, using the default string type, if needed
775    pub fn new() -> Self {
776        LabelBuilder {
777            _state: PhantomData,
778            _fields: (None, None, None, None, None, None, None, None, None),
779            _type: PhantomData,
780        }
781    }
782}
783
784impl<S: BosStr> LabelBuilder<label_state::Empty, S> {
785    /// Create a new builder with all fields unset
786    pub fn builder() -> Self {
787        LabelBuilder {
788            _state: PhantomData,
789            _fields: (None, None, None, None, None, None, None, None, None),
790            _type: PhantomData,
791        }
792    }
793}
794
795impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
796    /// Set the `cid` field (optional)
797    pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
798        self._fields.0 = value.into();
799        self
800    }
801    /// Set the `cid` field to an Option value (optional)
802    pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
803        self._fields.0 = value;
804        self
805    }
806}
807
808impl<St, S: BosStr> LabelBuilder<St, S>
809where
810    St: label_state::State,
811    St::Cts: label_state::IsUnset,
812{
813    /// Set the `cts` field (required)
814    pub fn cts(
815        mut self,
816        value: impl Into<Datetime>,
817    ) -> LabelBuilder<label_state::SetCts<St>, S> {
818        self._fields.1 = Option::Some(value.into());
819        LabelBuilder {
820            _state: PhantomData,
821            _fields: self._fields,
822            _type: PhantomData,
823        }
824    }
825}
826
827impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
828    /// Set the `exp` field (optional)
829    pub fn exp(mut self, value: impl Into<Option<Datetime>>) -> Self {
830        self._fields.2 = value.into();
831        self
832    }
833    /// Set the `exp` field to an Option value (optional)
834    pub fn maybe_exp(mut self, value: Option<Datetime>) -> Self {
835        self._fields.2 = value;
836        self
837    }
838}
839
840impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
841    /// Set the `neg` field (optional)
842    pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self {
843        self._fields.3 = value.into();
844        self
845    }
846    /// Set the `neg` field to an Option value (optional)
847    pub fn maybe_neg(mut self, value: Option<bool>) -> Self {
848        self._fields.3 = value;
849        self
850    }
851}
852
853impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
854    /// Set the `sig` field (optional)
855    pub fn sig(mut self, value: impl Into<Option<Bytes>>) -> Self {
856        self._fields.4 = value.into();
857        self
858    }
859    /// Set the `sig` field to an Option value (optional)
860    pub fn maybe_sig(mut self, value: Option<Bytes>) -> Self {
861        self._fields.4 = value;
862        self
863    }
864}
865
866impl<St, S: BosStr> LabelBuilder<St, S>
867where
868    St: label_state::State,
869    St::Src: label_state::IsUnset,
870{
871    /// Set the `src` field (required)
872    pub fn src(
873        mut self,
874        value: impl Into<Did<S>>,
875    ) -> LabelBuilder<label_state::SetSrc<St>, S> {
876        self._fields.5 = Option::Some(value.into());
877        LabelBuilder {
878            _state: PhantomData,
879            _fields: self._fields,
880            _type: PhantomData,
881        }
882    }
883}
884
885impl<St, S: BosStr> LabelBuilder<St, S>
886where
887    St: label_state::State,
888    St::Uri: label_state::IsUnset,
889{
890    /// Set the `uri` field (required)
891    pub fn uri(
892        mut self,
893        value: impl Into<UriValue<S>>,
894    ) -> LabelBuilder<label_state::SetUri<St>, S> {
895        self._fields.6 = Option::Some(value.into());
896        LabelBuilder {
897            _state: PhantomData,
898            _fields: self._fields,
899            _type: PhantomData,
900        }
901    }
902}
903
904impl<St, S: BosStr> LabelBuilder<St, S>
905where
906    St: label_state::State,
907    St::Val: label_state::IsUnset,
908{
909    /// Set the `val` field (required)
910    pub fn val(
911        mut self,
912        value: impl Into<S>,
913    ) -> LabelBuilder<label_state::SetVal<St>, S> {
914        self._fields.7 = Option::Some(value.into());
915        LabelBuilder {
916            _state: PhantomData,
917            _fields: self._fields,
918            _type: PhantomData,
919        }
920    }
921}
922
923impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
924    /// Set the `ver` field (optional)
925    pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self {
926        self._fields.8 = value.into();
927        self
928    }
929    /// Set the `ver` field to an Option value (optional)
930    pub fn maybe_ver(mut self, value: Option<i64>) -> Self {
931        self._fields.8 = value;
932        self
933    }
934}
935
936impl<St, S: BosStr> LabelBuilder<St, S>
937where
938    St: label_state::State,
939    St::Cts: label_state::IsSet,
940    St::Src: label_state::IsSet,
941    St::Uri: label_state::IsSet,
942    St::Val: label_state::IsSet,
943{
944    /// Build the final struct.
945    pub fn build(self) -> Label<S> {
946        Label {
947            cid: self._fields.0,
948            cts: self._fields.1.unwrap(),
949            exp: self._fields.2,
950            neg: self._fields.3,
951            sig: self._fields.4,
952            src: self._fields.5.unwrap(),
953            uri: self._fields.6.unwrap(),
954            val: self._fields.7.unwrap(),
955            ver: self._fields.8,
956            extra_data: Default::default(),
957        }
958    }
959    /// Build the final struct with custom extra_data.
960    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Label<S> {
961        Label {
962            cid: self._fields.0,
963            cts: self._fields.1.unwrap(),
964            exp: self._fields.2,
965            neg: self._fields.3,
966            sig: self._fields.4,
967            src: self._fields.5.unwrap(),
968            uri: self._fields.6.unwrap(),
969            val: self._fields.7.unwrap(),
970            ver: self._fields.8,
971            extra_data: Some(extra_data),
972        }
973    }
974}
975
976fn lexicon_doc_com_atproto_label_defs() -> LexiconDoc<'static> {
977    #[allow(unused_imports)]
978    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
979    use jacquard_lexicon::lexicon::*;
980    use alloc::collections::BTreeMap;
981    LexiconDoc {
982        lexicon: Lexicon::Lexicon1,
983        id: CowStr::new_static("com.atproto.label.defs"),
984        defs: {
985            let mut map = BTreeMap::new();
986            map.insert(
987                SmolStr::new_static("label"),
988                LexUserType::Object(LexObject {
989                    description: Some(
990                        CowStr::new_static(
991                            "Metadata tag on an atproto resource (eg, repo or record).",
992                        ),
993                    ),
994                    required: Some(
995                        vec![
996                            SmolStr::new_static("src"), SmolStr::new_static("uri"),
997                            SmolStr::new_static("val"), SmolStr::new_static("cts")
998                        ],
999                    ),
1000                    properties: {
1001                        #[allow(unused_mut)]
1002                        let mut map = BTreeMap::new();
1003                        map.insert(
1004                            SmolStr::new_static("cid"),
1005                            LexObjectProperty::String(LexString {
1006                                description: Some(
1007                                    CowStr::new_static(
1008                                        "Optionally, CID specifying the specific version of 'uri' resource this label applies to.",
1009                                    ),
1010                                ),
1011                                format: Some(LexStringFormat::Cid),
1012                                ..Default::default()
1013                            }),
1014                        );
1015                        map.insert(
1016                            SmolStr::new_static("cts"),
1017                            LexObjectProperty::String(LexString {
1018                                description: Some(
1019                                    CowStr::new_static("Timestamp when this label was created."),
1020                                ),
1021                                format: Some(LexStringFormat::Datetime),
1022                                ..Default::default()
1023                            }),
1024                        );
1025                        map.insert(
1026                            SmolStr::new_static("exp"),
1027                            LexObjectProperty::String(LexString {
1028                                description: Some(
1029                                    CowStr::new_static(
1030                                        "Timestamp at which this label expires (no longer applies).",
1031                                    ),
1032                                ),
1033                                format: Some(LexStringFormat::Datetime),
1034                                ..Default::default()
1035                            }),
1036                        );
1037                        map.insert(
1038                            SmolStr::new_static("neg"),
1039                            LexObjectProperty::Boolean(LexBoolean {
1040                                ..Default::default()
1041                            }),
1042                        );
1043                        map.insert(
1044                            SmolStr::new_static("sig"),
1045                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
1046                        );
1047                        map.insert(
1048                            SmolStr::new_static("src"),
1049                            LexObjectProperty::String(LexString {
1050                                description: Some(
1051                                    CowStr::new_static(
1052                                        "DID of the actor who created this label.",
1053                                    ),
1054                                ),
1055                                format: Some(LexStringFormat::Did),
1056                                ..Default::default()
1057                            }),
1058                        );
1059                        map.insert(
1060                            SmolStr::new_static("uri"),
1061                            LexObjectProperty::String(LexString {
1062                                description: Some(
1063                                    CowStr::new_static(
1064                                        "AT URI of the record, repository (account), or other resource that this label applies to.",
1065                                    ),
1066                                ),
1067                                format: Some(LexStringFormat::Uri),
1068                                ..Default::default()
1069                            }),
1070                        );
1071                        map.insert(
1072                            SmolStr::new_static("val"),
1073                            LexObjectProperty::String(LexString {
1074                                description: Some(
1075                                    CowStr::new_static(
1076                                        "The short string name of the value or type of this label.",
1077                                    ),
1078                                ),
1079                                max_length: Some(128usize),
1080                                ..Default::default()
1081                            }),
1082                        );
1083                        map.insert(
1084                            SmolStr::new_static("ver"),
1085                            LexObjectProperty::Integer(LexInteger {
1086                                ..Default::default()
1087                            }),
1088                        );
1089                        map
1090                    },
1091                    ..Default::default()
1092                }),
1093            );
1094            map.insert(
1095                SmolStr::new_static("labelValue"),
1096                LexUserType::String(LexString { ..Default::default() }),
1097            );
1098            map.insert(
1099                SmolStr::new_static("labelValueDefinition"),
1100                LexUserType::Object(LexObject {
1101                    description: Some(
1102                        CowStr::new_static(
1103                            "Declares a label value and its expected interpretations and behaviors.",
1104                        ),
1105                    ),
1106                    required: Some(
1107                        vec![
1108                            SmolStr::new_static("identifier"),
1109                            SmolStr::new_static("severity"),
1110                            SmolStr::new_static("blurs"), SmolStr::new_static("locales")
1111                        ],
1112                    ),
1113                    properties: {
1114                        #[allow(unused_mut)]
1115                        let mut map = BTreeMap::new();
1116                        map.insert(
1117                            SmolStr::new_static("adultOnly"),
1118                            LexObjectProperty::Boolean(LexBoolean {
1119                                ..Default::default()
1120                            }),
1121                        );
1122                        map.insert(
1123                            SmolStr::new_static("blurs"),
1124                            LexObjectProperty::String(LexString {
1125                                description: Some(
1126                                    CowStr::new_static(
1127                                        "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
1128                                    ),
1129                                ),
1130                                ..Default::default()
1131                            }),
1132                        );
1133                        map.insert(
1134                            SmolStr::new_static("defaultSetting"),
1135                            LexObjectProperty::String(LexString {
1136                                description: Some(
1137                                    CowStr::new_static("The default setting for this label."),
1138                                ),
1139                                ..Default::default()
1140                            }),
1141                        );
1142                        map.insert(
1143                            SmolStr::new_static("identifier"),
1144                            LexObjectProperty::String(LexString {
1145                                description: Some(
1146                                    CowStr::new_static(
1147                                        "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
1148                                    ),
1149                                ),
1150                                max_length: Some(100usize),
1151                                max_graphemes: Some(100usize),
1152                                ..Default::default()
1153                            }),
1154                        );
1155                        map.insert(
1156                            SmolStr::new_static("locales"),
1157                            LexObjectProperty::Array(LexArray {
1158                                items: LexArrayItem::Ref(LexRef {
1159                                    r#ref: CowStr::new_static("#labelValueDefinitionStrings"),
1160                                    ..Default::default()
1161                                }),
1162                                ..Default::default()
1163                            }),
1164                        );
1165                        map.insert(
1166                            SmolStr::new_static("severity"),
1167                            LexObjectProperty::String(LexString {
1168                                description: Some(
1169                                    CowStr::new_static(
1170                                        "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
1171                                    ),
1172                                ),
1173                                ..Default::default()
1174                            }),
1175                        );
1176                        map
1177                    },
1178                    ..Default::default()
1179                }),
1180            );
1181            map.insert(
1182                SmolStr::new_static("labelValueDefinitionStrings"),
1183                LexUserType::Object(LexObject {
1184                    description: Some(
1185                        CowStr::new_static(
1186                            "Strings which describe the label in the UI, localized into a specific language.",
1187                        ),
1188                    ),
1189                    required: Some(
1190                        vec![
1191                            SmolStr::new_static("lang"), SmolStr::new_static("name"),
1192                            SmolStr::new_static("description")
1193                        ],
1194                    ),
1195                    properties: {
1196                        #[allow(unused_mut)]
1197                        let mut map = BTreeMap::new();
1198                        map.insert(
1199                            SmolStr::new_static("description"),
1200                            LexObjectProperty::String(LexString {
1201                                description: Some(
1202                                    CowStr::new_static(
1203                                        "A longer description of what the label means and why it might be applied.",
1204                                    ),
1205                                ),
1206                                max_length: Some(100000usize),
1207                                max_graphemes: Some(10000usize),
1208                                ..Default::default()
1209                            }),
1210                        );
1211                        map.insert(
1212                            SmolStr::new_static("lang"),
1213                            LexObjectProperty::String(LexString {
1214                                description: Some(
1215                                    CowStr::new_static(
1216                                        "The code of the language these strings are written in.",
1217                                    ),
1218                                ),
1219                                format: Some(LexStringFormat::Language),
1220                                ..Default::default()
1221                            }),
1222                        );
1223                        map.insert(
1224                            SmolStr::new_static("name"),
1225                            LexObjectProperty::String(LexString {
1226                                description: Some(
1227                                    CowStr::new_static(
1228                                        "A short human-readable name for the label.",
1229                                    ),
1230                                ),
1231                                max_length: Some(640usize),
1232                                max_graphemes: Some(64usize),
1233                                ..Default::default()
1234                            }),
1235                        );
1236                        map
1237                    },
1238                    ..Default::default()
1239                }),
1240            );
1241            map.insert(
1242                SmolStr::new_static("selfLabel"),
1243                LexUserType::Object(LexObject {
1244                    description: Some(
1245                        CowStr::new_static(
1246                            "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.",
1247                        ),
1248                    ),
1249                    required: Some(vec![SmolStr::new_static("val")]),
1250                    properties: {
1251                        #[allow(unused_mut)]
1252                        let mut map = BTreeMap::new();
1253                        map.insert(
1254                            SmolStr::new_static("val"),
1255                            LexObjectProperty::String(LexString {
1256                                description: Some(
1257                                    CowStr::new_static(
1258                                        "The short string name of the value or type of this label.",
1259                                    ),
1260                                ),
1261                                max_length: Some(128usize),
1262                                ..Default::default()
1263                            }),
1264                        );
1265                        map
1266                    },
1267                    ..Default::default()
1268                }),
1269            );
1270            map.insert(
1271                SmolStr::new_static("selfLabels"),
1272                LexUserType::Object(LexObject {
1273                    description: Some(
1274                        CowStr::new_static(
1275                            "Metadata tags on an atproto record, published by the author within the record.",
1276                        ),
1277                    ),
1278                    required: Some(vec![SmolStr::new_static("values")]),
1279                    properties: {
1280                        #[allow(unused_mut)]
1281                        let mut map = BTreeMap::new();
1282                        map.insert(
1283                            SmolStr::new_static("values"),
1284                            LexObjectProperty::Array(LexArray {
1285                                items: LexArrayItem::Ref(LexRef {
1286                                    r#ref: CowStr::new_static("#selfLabel"),
1287                                    ..Default::default()
1288                                }),
1289                                max_length: Some(10usize),
1290                                ..Default::default()
1291                            }),
1292                        );
1293                        map
1294                    },
1295                    ..Default::default()
1296                }),
1297            );
1298            map
1299        },
1300        ..Default::default()
1301    }
1302}
1303
1304pub mod label_value_definition_state {
1305
1306    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1307    #[allow(unused)]
1308    use ::core::marker::PhantomData;
1309    mod sealed {
1310        pub trait Sealed {}
1311    }
1312    /// State trait tracking which required fields have been set
1313    pub trait State: sealed::Sealed {
1314        type Blurs;
1315        type Identifier;
1316        type Locales;
1317        type Severity;
1318    }
1319    /// Empty state - all required fields are unset
1320    pub struct Empty(());
1321    impl sealed::Sealed for Empty {}
1322    impl State for Empty {
1323        type Blurs = Unset;
1324        type Identifier = Unset;
1325        type Locales = Unset;
1326        type Severity = Unset;
1327    }
1328    ///State transition - sets the `blurs` field to Set
1329    pub struct SetBlurs<St: State = Empty>(PhantomData<fn() -> St>);
1330    impl<St: State> sealed::Sealed for SetBlurs<St> {}
1331    impl<St: State> State for SetBlurs<St> {
1332        type Blurs = Set<members::blurs>;
1333        type Identifier = St::Identifier;
1334        type Locales = St::Locales;
1335        type Severity = St::Severity;
1336    }
1337    ///State transition - sets the `identifier` field to Set
1338    pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>);
1339    impl<St: State> sealed::Sealed for SetIdentifier<St> {}
1340    impl<St: State> State for SetIdentifier<St> {
1341        type Blurs = St::Blurs;
1342        type Identifier = Set<members::identifier>;
1343        type Locales = St::Locales;
1344        type Severity = St::Severity;
1345    }
1346    ///State transition - sets the `locales` field to Set
1347    pub struct SetLocales<St: State = Empty>(PhantomData<fn() -> St>);
1348    impl<St: State> sealed::Sealed for SetLocales<St> {}
1349    impl<St: State> State for SetLocales<St> {
1350        type Blurs = St::Blurs;
1351        type Identifier = St::Identifier;
1352        type Locales = Set<members::locales>;
1353        type Severity = St::Severity;
1354    }
1355    ///State transition - sets the `severity` field to Set
1356    pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>);
1357    impl<St: State> sealed::Sealed for SetSeverity<St> {}
1358    impl<St: State> State for SetSeverity<St> {
1359        type Blurs = St::Blurs;
1360        type Identifier = St::Identifier;
1361        type Locales = St::Locales;
1362        type Severity = Set<members::severity>;
1363    }
1364    /// Marker types for field names
1365    #[allow(non_camel_case_types)]
1366    pub mod members {
1367        ///Marker type for the `blurs` field
1368        pub struct blurs(());
1369        ///Marker type for the `identifier` field
1370        pub struct identifier(());
1371        ///Marker type for the `locales` field
1372        pub struct locales(());
1373        ///Marker type for the `severity` field
1374        pub struct severity(());
1375    }
1376}
1377
1378/// Builder for constructing an instance of this type.
1379pub struct LabelValueDefinitionBuilder<
1380    St: label_value_definition_state::State,
1381    S: BosStr = DefaultStr,
1382> {
1383    _state: PhantomData<fn() -> St>,
1384    _fields: (
1385        Option<bool>,
1386        Option<LabelValueDefinitionBlurs<S>>,
1387        Option<LabelValueDefinitionDefaultSetting<S>>,
1388        Option<S>,
1389        Option<Vec<label::LabelValueDefinitionStrings<S>>>,
1390        Option<LabelValueDefinitionSeverity<S>>,
1391    ),
1392    _type: PhantomData<fn() -> S>,
1393}
1394
1395impl LabelValueDefinition<DefaultStr> {
1396    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
1397    pub fn new() -> LabelValueDefinitionBuilder<
1398        label_value_definition_state::Empty,
1399        DefaultStr,
1400    > {
1401        LabelValueDefinitionBuilder::new()
1402    }
1403}
1404
1405impl<S: BosStr> LabelValueDefinition<S> {
1406    /// Create a new builder for this type
1407    pub fn builder() -> LabelValueDefinitionBuilder<
1408        label_value_definition_state::Empty,
1409        S,
1410    > {
1411        LabelValueDefinitionBuilder::builder()
1412    }
1413}
1414
1415impl LabelValueDefinitionBuilder<label_value_definition_state::Empty, DefaultStr> {
1416    /// Create a new builder with all fields unset, using the default string type, if needed
1417    pub fn new() -> Self {
1418        LabelValueDefinitionBuilder {
1419            _state: PhantomData,
1420            _fields: (None, None, None, None, None, None),
1421            _type: PhantomData,
1422        }
1423    }
1424}
1425
1426impl<S: BosStr> LabelValueDefinitionBuilder<label_value_definition_state::Empty, S> {
1427    /// Create a new builder with all fields unset
1428    pub fn builder() -> Self {
1429        LabelValueDefinitionBuilder {
1430            _state: PhantomData,
1431            _fields: (None, None, None, None, None, None),
1432            _type: PhantomData,
1433        }
1434    }
1435}
1436
1437impl<
1438    St: label_value_definition_state::State,
1439    S: BosStr,
1440> LabelValueDefinitionBuilder<St, S> {
1441    /// Set the `adultOnly` field (optional)
1442    pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self {
1443        self._fields.0 = value.into();
1444        self
1445    }
1446    /// Set the `adultOnly` field to an Option value (optional)
1447    pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self {
1448        self._fields.0 = value;
1449        self
1450    }
1451}
1452
1453impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
1454where
1455    St: label_value_definition_state::State,
1456    St::Blurs: label_value_definition_state::IsUnset,
1457{
1458    /// Set the `blurs` field (required)
1459    pub fn blurs(
1460        mut self,
1461        value: impl Into<LabelValueDefinitionBlurs<S>>,
1462    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetBlurs<St>, S> {
1463        self._fields.1 = Option::Some(value.into());
1464        LabelValueDefinitionBuilder {
1465            _state: PhantomData,
1466            _fields: self._fields,
1467            _type: PhantomData,
1468        }
1469    }
1470}
1471
1472impl<
1473    St: label_value_definition_state::State,
1474    S: BosStr,
1475> LabelValueDefinitionBuilder<St, S> {
1476    /// Set the `defaultSetting` field (optional)
1477    pub fn default_setting(
1478        mut self,
1479        value: impl Into<Option<LabelValueDefinitionDefaultSetting<S>>>,
1480    ) -> Self {
1481        self._fields.2 = value.into();
1482        self
1483    }
1484    /// Set the `defaultSetting` field to an Option value (optional)
1485    pub fn maybe_default_setting(
1486        mut self,
1487        value: Option<LabelValueDefinitionDefaultSetting<S>>,
1488    ) -> Self {
1489        self._fields.2 = value;
1490        self
1491    }
1492}
1493
1494impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
1495where
1496    St: label_value_definition_state::State,
1497    St::Identifier: label_value_definition_state::IsUnset,
1498{
1499    /// Set the `identifier` field (required)
1500    pub fn identifier(
1501        mut self,
1502        value: impl Into<S>,
1503    ) -> LabelValueDefinitionBuilder<
1504        label_value_definition_state::SetIdentifier<St>,
1505        S,
1506    > {
1507        self._fields.3 = Option::Some(value.into());
1508        LabelValueDefinitionBuilder {
1509            _state: PhantomData,
1510            _fields: self._fields,
1511            _type: PhantomData,
1512        }
1513    }
1514}
1515
1516impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
1517where
1518    St: label_value_definition_state::State,
1519    St::Locales: label_value_definition_state::IsUnset,
1520{
1521    /// Set the `locales` field (required)
1522    pub fn locales(
1523        mut self,
1524        value: impl Into<Vec<label::LabelValueDefinitionStrings<S>>>,
1525    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetLocales<St>, S> {
1526        self._fields.4 = Option::Some(value.into());
1527        LabelValueDefinitionBuilder {
1528            _state: PhantomData,
1529            _fields: self._fields,
1530            _type: PhantomData,
1531        }
1532    }
1533}
1534
1535impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
1536where
1537    St: label_value_definition_state::State,
1538    St::Severity: label_value_definition_state::IsUnset,
1539{
1540    /// Set the `severity` field (required)
1541    pub fn severity(
1542        mut self,
1543        value: impl Into<LabelValueDefinitionSeverity<S>>,
1544    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetSeverity<St>, S> {
1545        self._fields.5 = Option::Some(value.into());
1546        LabelValueDefinitionBuilder {
1547            _state: PhantomData,
1548            _fields: self._fields,
1549            _type: PhantomData,
1550        }
1551    }
1552}
1553
1554impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
1555where
1556    St: label_value_definition_state::State,
1557    St::Blurs: label_value_definition_state::IsSet,
1558    St::Identifier: label_value_definition_state::IsSet,
1559    St::Locales: label_value_definition_state::IsSet,
1560    St::Severity: label_value_definition_state::IsSet,
1561{
1562    /// Build the final struct.
1563    pub fn build(self) -> LabelValueDefinition<S> {
1564        LabelValueDefinition {
1565            adult_only: self._fields.0,
1566            blurs: self._fields.1.unwrap(),
1567            default_setting: self._fields.2,
1568            identifier: self._fields.3.unwrap(),
1569            locales: self._fields.4.unwrap(),
1570            severity: self._fields.5.unwrap(),
1571            extra_data: Default::default(),
1572        }
1573    }
1574    /// Build the final struct with custom extra_data.
1575    pub fn build_with_data(
1576        self,
1577        extra_data: BTreeMap<SmolStr, Data<S>>,
1578    ) -> LabelValueDefinition<S> {
1579        LabelValueDefinition {
1580            adult_only: self._fields.0,
1581            blurs: self._fields.1.unwrap(),
1582            default_setting: self._fields.2,
1583            identifier: self._fields.3.unwrap(),
1584            locales: self._fields.4.unwrap(),
1585            severity: self._fields.5.unwrap(),
1586            extra_data: Some(extra_data),
1587        }
1588    }
1589}
1590
1591pub mod label_value_definition_strings_state {
1592
1593    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1594    #[allow(unused)]
1595    use ::core::marker::PhantomData;
1596    mod sealed {
1597        pub trait Sealed {}
1598    }
1599    /// State trait tracking which required fields have been set
1600    pub trait State: sealed::Sealed {
1601        type Description;
1602        type Lang;
1603        type Name;
1604    }
1605    /// Empty state - all required fields are unset
1606    pub struct Empty(());
1607    impl sealed::Sealed for Empty {}
1608    impl State for Empty {
1609        type Description = Unset;
1610        type Lang = Unset;
1611        type Name = Unset;
1612    }
1613    ///State transition - sets the `description` field to Set
1614    pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
1615    impl<St: State> sealed::Sealed for SetDescription<St> {}
1616    impl<St: State> State for SetDescription<St> {
1617        type Description = Set<members::description>;
1618        type Lang = St::Lang;
1619        type Name = St::Name;
1620    }
1621    ///State transition - sets the `lang` field to Set
1622    pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
1623    impl<St: State> sealed::Sealed for SetLang<St> {}
1624    impl<St: State> State for SetLang<St> {
1625        type Description = St::Description;
1626        type Lang = Set<members::lang>;
1627        type Name = St::Name;
1628    }
1629    ///State transition - sets the `name` field to Set
1630    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
1631    impl<St: State> sealed::Sealed for SetName<St> {}
1632    impl<St: State> State for SetName<St> {
1633        type Description = St::Description;
1634        type Lang = St::Lang;
1635        type Name = Set<members::name>;
1636    }
1637    /// Marker types for field names
1638    #[allow(non_camel_case_types)]
1639    pub mod members {
1640        ///Marker type for the `description` field
1641        pub struct description(());
1642        ///Marker type for the `lang` field
1643        pub struct lang(());
1644        ///Marker type for the `name` field
1645        pub struct name(());
1646    }
1647}
1648
1649/// Builder for constructing an instance of this type.
1650pub struct LabelValueDefinitionStringsBuilder<
1651    St: label_value_definition_strings_state::State,
1652    S: BosStr = DefaultStr,
1653> {
1654    _state: PhantomData<fn() -> St>,
1655    _fields: (Option<S>, Option<Language>, Option<S>),
1656    _type: PhantomData<fn() -> S>,
1657}
1658
1659impl LabelValueDefinitionStrings<DefaultStr> {
1660    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
1661    pub fn new() -> LabelValueDefinitionStringsBuilder<
1662        label_value_definition_strings_state::Empty,
1663        DefaultStr,
1664    > {
1665        LabelValueDefinitionStringsBuilder::new()
1666    }
1667}
1668
1669impl<S: BosStr> LabelValueDefinitionStrings<S> {
1670    /// Create a new builder for this type
1671    pub fn builder() -> LabelValueDefinitionStringsBuilder<
1672        label_value_definition_strings_state::Empty,
1673        S,
1674    > {
1675        LabelValueDefinitionStringsBuilder::builder()
1676    }
1677}
1678
1679impl LabelValueDefinitionStringsBuilder<
1680    label_value_definition_strings_state::Empty,
1681    DefaultStr,
1682> {
1683    /// Create a new builder with all fields unset, using the default string type, if needed
1684    pub fn new() -> Self {
1685        LabelValueDefinitionStringsBuilder {
1686            _state: PhantomData,
1687            _fields: (None, None, None),
1688            _type: PhantomData,
1689        }
1690    }
1691}
1692
1693impl<
1694    S: BosStr,
1695> LabelValueDefinitionStringsBuilder<label_value_definition_strings_state::Empty, S> {
1696    /// Create a new builder with all fields unset
1697    pub fn builder() -> Self {
1698        LabelValueDefinitionStringsBuilder {
1699            _state: PhantomData,
1700            _fields: (None, None, None),
1701            _type: PhantomData,
1702        }
1703    }
1704}
1705
1706impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
1707where
1708    St: label_value_definition_strings_state::State,
1709    St::Description: label_value_definition_strings_state::IsUnset,
1710{
1711    /// Set the `description` field (required)
1712    pub fn description(
1713        mut self,
1714        value: impl Into<S>,
1715    ) -> LabelValueDefinitionStringsBuilder<
1716        label_value_definition_strings_state::SetDescription<St>,
1717        S,
1718    > {
1719        self._fields.0 = Option::Some(value.into());
1720        LabelValueDefinitionStringsBuilder {
1721            _state: PhantomData,
1722            _fields: self._fields,
1723            _type: PhantomData,
1724        }
1725    }
1726}
1727
1728impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
1729where
1730    St: label_value_definition_strings_state::State,
1731    St::Lang: label_value_definition_strings_state::IsUnset,
1732{
1733    /// Set the `lang` field (required)
1734    pub fn lang(
1735        mut self,
1736        value: impl Into<Language>,
1737    ) -> LabelValueDefinitionStringsBuilder<
1738        label_value_definition_strings_state::SetLang<St>,
1739        S,
1740    > {
1741        self._fields.1 = Option::Some(value.into());
1742        LabelValueDefinitionStringsBuilder {
1743            _state: PhantomData,
1744            _fields: self._fields,
1745            _type: PhantomData,
1746        }
1747    }
1748}
1749
1750impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
1751where
1752    St: label_value_definition_strings_state::State,
1753    St::Name: label_value_definition_strings_state::IsUnset,
1754{
1755    /// Set the `name` field (required)
1756    pub fn name(
1757        mut self,
1758        value: impl Into<S>,
1759    ) -> LabelValueDefinitionStringsBuilder<
1760        label_value_definition_strings_state::SetName<St>,
1761        S,
1762    > {
1763        self._fields.2 = Option::Some(value.into());
1764        LabelValueDefinitionStringsBuilder {
1765            _state: PhantomData,
1766            _fields: self._fields,
1767            _type: PhantomData,
1768        }
1769    }
1770}
1771
1772impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
1773where
1774    St: label_value_definition_strings_state::State,
1775    St::Description: label_value_definition_strings_state::IsSet,
1776    St::Lang: label_value_definition_strings_state::IsSet,
1777    St::Name: label_value_definition_strings_state::IsSet,
1778{
1779    /// Build the final struct.
1780    pub fn build(self) -> LabelValueDefinitionStrings<S> {
1781        LabelValueDefinitionStrings {
1782            description: self._fields.0.unwrap(),
1783            lang: self._fields.1.unwrap(),
1784            name: self._fields.2.unwrap(),
1785            extra_data: Default::default(),
1786        }
1787    }
1788    /// Build the final struct with custom extra_data.
1789    pub fn build_with_data(
1790        self,
1791        extra_data: BTreeMap<SmolStr, Data<S>>,
1792    ) -> LabelValueDefinitionStrings<S> {
1793        LabelValueDefinitionStrings {
1794            description: self._fields.0.unwrap(),
1795            lang: self._fields.1.unwrap(),
1796            name: self._fields.2.unwrap(),
1797            extra_data: Some(extra_data),
1798        }
1799    }
1800}
1801
1802pub mod self_labels_state {
1803
1804    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1805    #[allow(unused)]
1806    use ::core::marker::PhantomData;
1807    mod sealed {
1808        pub trait Sealed {}
1809    }
1810    /// State trait tracking which required fields have been set
1811    pub trait State: sealed::Sealed {
1812        type Values;
1813    }
1814    /// Empty state - all required fields are unset
1815    pub struct Empty(());
1816    impl sealed::Sealed for Empty {}
1817    impl State for Empty {
1818        type Values = Unset;
1819    }
1820    ///State transition - sets the `values` field to Set
1821    pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>);
1822    impl<St: State> sealed::Sealed for SetValues<St> {}
1823    impl<St: State> State for SetValues<St> {
1824        type Values = Set<members::values>;
1825    }
1826    /// Marker types for field names
1827    #[allow(non_camel_case_types)]
1828    pub mod members {
1829        ///Marker type for the `values` field
1830        pub struct values(());
1831    }
1832}
1833
1834/// Builder for constructing an instance of this type.
1835pub struct SelfLabelsBuilder<St: self_labels_state::State, S: BosStr = DefaultStr> {
1836    _state: PhantomData<fn() -> St>,
1837    _fields: (Option<Vec<label::SelfLabel<S>>>,),
1838    _type: PhantomData<fn() -> S>,
1839}
1840
1841impl SelfLabels<DefaultStr> {
1842    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
1843    pub fn new() -> SelfLabelsBuilder<self_labels_state::Empty, DefaultStr> {
1844        SelfLabelsBuilder::new()
1845    }
1846}
1847
1848impl<S: BosStr> SelfLabels<S> {
1849    /// Create a new builder for this type
1850    pub fn builder() -> SelfLabelsBuilder<self_labels_state::Empty, S> {
1851        SelfLabelsBuilder::builder()
1852    }
1853}
1854
1855impl SelfLabelsBuilder<self_labels_state::Empty, DefaultStr> {
1856    /// Create a new builder with all fields unset, using the default string type, if needed
1857    pub fn new() -> Self {
1858        SelfLabelsBuilder {
1859            _state: PhantomData,
1860            _fields: (None,),
1861            _type: PhantomData,
1862        }
1863    }
1864}
1865
1866impl<S: BosStr> SelfLabelsBuilder<self_labels_state::Empty, S> {
1867    /// Create a new builder with all fields unset
1868    pub fn builder() -> Self {
1869        SelfLabelsBuilder {
1870            _state: PhantomData,
1871            _fields: (None,),
1872            _type: PhantomData,
1873        }
1874    }
1875}
1876
1877impl<St, S: BosStr> SelfLabelsBuilder<St, S>
1878where
1879    St: self_labels_state::State,
1880    St::Values: self_labels_state::IsUnset,
1881{
1882    /// Set the `values` field (required)
1883    pub fn values(
1884        mut self,
1885        value: impl Into<Vec<label::SelfLabel<S>>>,
1886    ) -> SelfLabelsBuilder<self_labels_state::SetValues<St>, S> {
1887        self._fields.0 = Option::Some(value.into());
1888        SelfLabelsBuilder {
1889            _state: PhantomData,
1890            _fields: self._fields,
1891            _type: PhantomData,
1892        }
1893    }
1894}
1895
1896impl<St, S: BosStr> SelfLabelsBuilder<St, S>
1897where
1898    St: self_labels_state::State,
1899    St::Values: self_labels_state::IsSet,
1900{
1901    /// Build the final struct.
1902    pub fn build(self) -> SelfLabels<S> {
1903        SelfLabels {
1904            values: self._fields.0.unwrap(),
1905            extra_data: Default::default(),
1906        }
1907    }
1908    /// Build the final struct with custom extra_data.
1909    pub fn build_with_data(
1910        self,
1911        extra_data: BTreeMap<SmolStr, Data<S>>,
1912    ) -> SelfLabels<S> {
1913        SelfLabels {
1914            values: self._fields.0.unwrap(),
1915            extra_data: Some(extra_data),
1916        }
1917    }
1918}