Skip to main content

jacquard_api/place_stream/chat/
profile.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.chat.profile
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::collection::{Collection, RecordError};
19use jacquard_common::types::string::{Did, AtUri, Cid};
20use jacquard_common::types::uri::{RecordUri, UriError};
21use jacquard_common::types::value::Data;
22use jacquard_common::xrpc::XrpcResp;
23use jacquard_derive::{IntoStatic, lexicon};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27#[allow(unused_imports)]
28use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
29use serde::{Serialize, Deserialize};
30use crate::com_atproto::repo::strong_ref::StrongRef;
31use crate::place_stream::chat::profile;
32/// Selected badges for display in chat, organized by slot.
33
34#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
35#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
36pub struct BadgeSelections<S: BosStr = DefaultStr> {
37    ///Selected globally-issued badge (e.g. event badge).
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub global: Option<StrongRef<S>>,
40    ///Selected streamer-issued badges, one per streamer channel.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub streamer: Option<Vec<profile::StreamerBadgeSelection<S>>>,
43    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
44    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
45}
46
47/// Customizations for the color of a user's name in chat
48
49#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
50#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
51pub struct Color<S: BosStr = DefaultStr> {
52    pub blue: i64,
53    pub green: i64,
54    pub red: i64,
55    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
56    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
57}
58
59/// Record containing customizations for a user's chat profile.
60
61#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
62#[serde(
63    rename_all = "camelCase",
64    rename = "place.stream.chat.profile",
65    tag = "$type",
66    bound(deserialize = "S: Deserialize<'de> + BosStr")
67)]
68pub struct Profile<S: BosStr = DefaultStr> {
69    ///Badge selections for display in chat.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub badges: Option<profile::BadgeSelections<S>>,
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub color: Option<profile::Color<S>>,
74    ///Self-applied labels for this profile, e.g. 'bot'.
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub self_labels: Option<Vec<profile::SelfLabel<S>>>,
77    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
78    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
79}
80
81/// Typed wrapper for GetRecord response with this collection's record type.
82
83#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
84#[serde(rename_all = "camelCase")]
85pub struct ProfileGetRecordOutput<S: BosStr = DefaultStr> {
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub cid: Option<Cid<S>>,
88    pub uri: AtUri<S>,
89    pub value: Profile<S>,
90}
91
92/// Label that a user can apply to their own profile.
93
94#[derive(Debug, Clone, PartialEq, Eq, Hash)]
95pub enum SelfLabel<S: BosStr = DefaultStr> {
96    Bot,
97    Other(S),
98}
99
100impl<S: BosStr> SelfLabel<S> {
101    pub fn as_str(&self) -> &str {
102        match self {
103            Self::Bot => "bot",
104            Self::Other(s) => s.as_ref(),
105        }
106    }
107    /// Construct from a string-like value, matching known values.
108    pub fn from_value(s: S) -> Self {
109        match s.as_ref() {
110            "bot" => Self::Bot,
111            _ => Self::Other(s),
112        }
113    }
114}
115
116impl<S: BosStr> AsRef<str> for SelfLabel<S> {
117    fn as_ref(&self) -> &str {
118        self.as_str()
119    }
120}
121
122impl<S: BosStr> core::fmt::Display for SelfLabel<S> {
123    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
124        write!(f, "{}", self.as_str())
125    }
126}
127
128impl<S: BosStr> Serialize for SelfLabel<S> {
129    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
130    where
131        Ser: serde::Serializer,
132    {
133        serializer.serialize_str(self.as_str())
134    }
135}
136
137impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for SelfLabel<S> {
138    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
139    where
140        D: serde::Deserializer<'de>,
141    {
142        let s = S::deserialize(deserializer)?;
143        Ok(Self::from_value(s))
144    }
145}
146
147impl<S: BosStr> jacquard_common::IntoStatic for SelfLabel<S>
148where
149    S: BosStr + jacquard_common::IntoStatic,
150    S::Output: BosStr,
151{
152    type Output = SelfLabel<S::Output>;
153    fn into_static(self) -> Self::Output {
154        match self {
155            SelfLabel::Bot => SelfLabel::Bot,
156            SelfLabel::Other(v) => SelfLabel::Other(v.into_static()),
157        }
158    }
159}
160
161/// A selected badge for a specific streamer's channel.
162
163#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
164#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
165pub struct StreamerBadgeSelection<S: BosStr = DefaultStr> {
166    ///Strong reference to the selected place.stream.badge.issuance record.
167    pub badge: StrongRef<S>,
168    ///DID of the streamer whose channel this selection applies to.
169    pub streamer: Did<S>,
170    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
171    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
172}
173
174impl<S: BosStr> Profile<S> {
175    pub fn uri(uri: S) -> Result<RecordUri<S, ProfileRecord>, UriError> {
176        RecordUri::try_from_uri(AtUri::new(uri)?)
177    }
178}
179
180impl<S: BosStr> LexiconSchema for BadgeSelections<S> {
181    fn nsid() -> &'static str {
182        "place.stream.chat.profile"
183    }
184    fn def_name() -> &'static str {
185        "badgeSelections"
186    }
187    fn lexicon_doc() -> LexiconDoc<'static> {
188        lexicon_doc_place_stream_chat_profile()
189    }
190    fn validate(&self) -> Result<(), ConstraintError> {
191        if let Some(ref value) = self.streamer {
192            #[allow(unused_comparisons)]
193            if value.len() > 20usize {
194                return Err(ConstraintError::MaxLength {
195                    path: ValidationPath::from_field("streamer"),
196                    max: 20usize,
197                    actual: value.len(),
198                });
199            }
200        }
201        Ok(())
202    }
203}
204
205impl<S: BosStr> LexiconSchema for Color<S> {
206    fn nsid() -> &'static str {
207        "place.stream.chat.profile"
208    }
209    fn def_name() -> &'static str {
210        "color"
211    }
212    fn lexicon_doc() -> LexiconDoc<'static> {
213        lexicon_doc_place_stream_chat_profile()
214    }
215    fn validate(&self) -> Result<(), ConstraintError> {
216        {
217            let value = &self.blue;
218            if *value > 255i64 {
219                return Err(ConstraintError::Maximum {
220                    path: ValidationPath::from_field("blue"),
221                    max: 255i64,
222                    actual: *value,
223                });
224            }
225        }
226        {
227            let value = &self.blue;
228            if *value < 0i64 {
229                return Err(ConstraintError::Minimum {
230                    path: ValidationPath::from_field("blue"),
231                    min: 0i64,
232                    actual: *value,
233                });
234            }
235        }
236        {
237            let value = &self.green;
238            if *value > 255i64 {
239                return Err(ConstraintError::Maximum {
240                    path: ValidationPath::from_field("green"),
241                    max: 255i64,
242                    actual: *value,
243                });
244            }
245        }
246        {
247            let value = &self.green;
248            if *value < 0i64 {
249                return Err(ConstraintError::Minimum {
250                    path: ValidationPath::from_field("green"),
251                    min: 0i64,
252                    actual: *value,
253                });
254            }
255        }
256        {
257            let value = &self.red;
258            if *value > 255i64 {
259                return Err(ConstraintError::Maximum {
260                    path: ValidationPath::from_field("red"),
261                    max: 255i64,
262                    actual: *value,
263                });
264            }
265        }
266        {
267            let value = &self.red;
268            if *value < 0i64 {
269                return Err(ConstraintError::Minimum {
270                    path: ValidationPath::from_field("red"),
271                    min: 0i64,
272                    actual: *value,
273                });
274            }
275        }
276        Ok(())
277    }
278}
279
280/// Marker type for deserializing records from this collection.
281
282#[derive(Debug, Serialize, Deserialize)]
283pub struct ProfileRecord;
284impl XrpcResp for ProfileRecord {
285    const NSID: &'static str = "place.stream.chat.profile";
286    const ENCODING: &'static str = "application/json";
287    type Output<S: BosStr> = ProfileGetRecordOutput<S>;
288    type Err = RecordError;
289}
290
291impl<S: BosStr> From<ProfileGetRecordOutput<S>> for Profile<S> {
292    fn from(output: ProfileGetRecordOutput<S>) -> Self {
293        output.value
294    }
295}
296
297impl<S: BosStr> Collection for Profile<S> {
298    const NSID: &'static str = "place.stream.chat.profile";
299    type Record = ProfileRecord;
300}
301
302impl Collection for ProfileRecord {
303    const NSID: &'static str = "place.stream.chat.profile";
304    type Record = ProfileRecord;
305}
306
307impl<S: BosStr> LexiconSchema for Profile<S> {
308    fn nsid() -> &'static str {
309        "place.stream.chat.profile"
310    }
311    fn def_name() -> &'static str {
312        "main"
313    }
314    fn lexicon_doc() -> LexiconDoc<'static> {
315        lexicon_doc_place_stream_chat_profile()
316    }
317    fn validate(&self) -> Result<(), ConstraintError> {
318        if let Some(ref value) = self.self_labels {
319            #[allow(unused_comparisons)]
320            if value.len() > 10usize {
321                return Err(ConstraintError::MaxLength {
322                    path: ValidationPath::from_field("self_labels"),
323                    max: 10usize,
324                    actual: value.len(),
325                });
326            }
327        }
328        Ok(())
329    }
330}
331
332impl<S: BosStr> LexiconSchema for StreamerBadgeSelection<S> {
333    fn nsid() -> &'static str {
334        "place.stream.chat.profile"
335    }
336    fn def_name() -> &'static str {
337        "streamerBadgeSelection"
338    }
339    fn lexicon_doc() -> LexiconDoc<'static> {
340        lexicon_doc_place_stream_chat_profile()
341    }
342    fn validate(&self) -> Result<(), ConstraintError> {
343        Ok(())
344    }
345}
346
347fn lexicon_doc_place_stream_chat_profile() -> LexiconDoc<'static> {
348    #[allow(unused_imports)]
349    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
350    use jacquard_lexicon::lexicon::*;
351    use alloc::collections::BTreeMap;
352    LexiconDoc {
353        lexicon: Lexicon::Lexicon1,
354        id: CowStr::new_static("place.stream.chat.profile"),
355        defs: {
356            let mut map = BTreeMap::new();
357            map.insert(
358                SmolStr::new_static("badgeSelections"),
359                LexUserType::Object(LexObject {
360                    description: Some(
361                        CowStr::new_static(
362                            "Selected badges for display in chat, organized by slot.",
363                        ),
364                    ),
365                    properties: {
366                        #[allow(unused_mut)]
367                        let mut map = BTreeMap::new();
368                        map.insert(
369                            SmolStr::new_static("global"),
370                            LexObjectProperty::Ref(LexRef {
371                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
372                                ..Default::default()
373                            }),
374                        );
375                        map.insert(
376                            SmolStr::new_static("streamer"),
377                            LexObjectProperty::Array(LexArray {
378                                description: Some(
379                                    CowStr::new_static(
380                                        "Selected streamer-issued badges, one per streamer channel.",
381                                    ),
382                                ),
383                                items: LexArrayItem::Ref(LexRef {
384                                    r#ref: CowStr::new_static("#streamerBadgeSelection"),
385                                    ..Default::default()
386                                }),
387                                max_length: Some(20usize),
388                                ..Default::default()
389                            }),
390                        );
391                        map
392                    },
393                    ..Default::default()
394                }),
395            );
396            map.insert(
397                SmolStr::new_static("color"),
398                LexUserType::Object(LexObject {
399                    description: Some(
400                        CowStr::new_static(
401                            "Customizations for the color of a user's name in chat",
402                        ),
403                    ),
404                    required: Some(
405                        vec![
406                            SmolStr::new_static("red"), SmolStr::new_static("green"),
407                            SmolStr::new_static("blue")
408                        ],
409                    ),
410                    properties: {
411                        #[allow(unused_mut)]
412                        let mut map = BTreeMap::new();
413                        map.insert(
414                            SmolStr::new_static("blue"),
415                            LexObjectProperty::Integer(LexInteger {
416                                minimum: Some(0i64),
417                                maximum: Some(255i64),
418                                ..Default::default()
419                            }),
420                        );
421                        map.insert(
422                            SmolStr::new_static("green"),
423                            LexObjectProperty::Integer(LexInteger {
424                                minimum: Some(0i64),
425                                maximum: Some(255i64),
426                                ..Default::default()
427                            }),
428                        );
429                        map.insert(
430                            SmolStr::new_static("red"),
431                            LexObjectProperty::Integer(LexInteger {
432                                minimum: Some(0i64),
433                                maximum: Some(255i64),
434                                ..Default::default()
435                            }),
436                        );
437                        map
438                    },
439                    ..Default::default()
440                }),
441            );
442            map.insert(
443                SmolStr::new_static("main"),
444                LexUserType::Record(LexRecord {
445                    description: Some(
446                        CowStr::new_static(
447                            "Record containing customizations for a user's chat profile.",
448                        ),
449                    ),
450                    key: Some(CowStr::new_static("literal:self")),
451                    record: LexRecordRecord::Object(LexObject {
452                        required: Some(vec![]),
453                        properties: {
454                            #[allow(unused_mut)]
455                            let mut map = BTreeMap::new();
456                            map.insert(
457                                SmolStr::new_static("badges"),
458                                LexObjectProperty::Ref(LexRef {
459                                    r#ref: CowStr::new_static("#badgeSelections"),
460                                    ..Default::default()
461                                }),
462                            );
463                            map.insert(
464                                SmolStr::new_static("color"),
465                                LexObjectProperty::Ref(LexRef {
466                                    r#ref: CowStr::new_static("#color"),
467                                    ..Default::default()
468                                }),
469                            );
470                            map.insert(
471                                SmolStr::new_static("selfLabels"),
472                                LexObjectProperty::Array(LexArray {
473                                    description: Some(
474                                        CowStr::new_static(
475                                            "Self-applied labels for this profile, e.g. 'bot'.",
476                                        ),
477                                    ),
478                                    items: LexArrayItem::Ref(LexRef {
479                                        r#ref: CowStr::new_static("#selfLabel"),
480                                        ..Default::default()
481                                    }),
482                                    max_length: Some(10usize),
483                                    ..Default::default()
484                                }),
485                            );
486                            map
487                        },
488                        ..Default::default()
489                    }),
490                    ..Default::default()
491                }),
492            );
493            map.insert(
494                SmolStr::new_static("selfLabel"),
495                LexUserType::String(LexString {
496                    description: Some(
497                        CowStr::new_static(
498                            "Label that a user can apply to their own profile.",
499                        ),
500                    ),
501                    ..Default::default()
502                }),
503            );
504            map.insert(
505                SmolStr::new_static("streamerBadgeSelection"),
506                LexUserType::Object(LexObject {
507                    description: Some(
508                        CowStr::new_static(
509                            "A selected badge for a specific streamer's channel.",
510                        ),
511                    ),
512                    required: Some(
513                        vec![
514                            SmolStr::new_static("streamer"), SmolStr::new_static("badge")
515                        ],
516                    ),
517                    properties: {
518                        #[allow(unused_mut)]
519                        let mut map = BTreeMap::new();
520                        map.insert(
521                            SmolStr::new_static("badge"),
522                            LexObjectProperty::Ref(LexRef {
523                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
524                                ..Default::default()
525                            }),
526                        );
527                        map.insert(
528                            SmolStr::new_static("streamer"),
529                            LexObjectProperty::String(LexString {
530                                description: Some(
531                                    CowStr::new_static(
532                                        "DID of the streamer whose channel this selection applies to.",
533                                    ),
534                                ),
535                                format: Some(LexStringFormat::Did),
536                                ..Default::default()
537                            }),
538                        );
539                        map
540                    },
541                    ..Default::default()
542                }),
543            );
544            map
545        },
546        ..Default::default()
547    }
548}
549
550pub mod color_state {
551
552    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
553    #[allow(unused)]
554    use ::core::marker::PhantomData;
555    mod sealed {
556        pub trait Sealed {}
557    }
558    /// State trait tracking which required fields have been set
559    pub trait State: sealed::Sealed {
560        type Blue;
561        type Green;
562        type Red;
563    }
564    /// Empty state - all required fields are unset
565    pub struct Empty(());
566    impl sealed::Sealed for Empty {}
567    impl State for Empty {
568        type Blue = Unset;
569        type Green = Unset;
570        type Red = Unset;
571    }
572    ///State transition - sets the `blue` field to Set
573    pub struct SetBlue<St: State = Empty>(PhantomData<fn() -> St>);
574    impl<St: State> sealed::Sealed for SetBlue<St> {}
575    impl<St: State> State for SetBlue<St> {
576        type Blue = Set<members::blue>;
577        type Green = St::Green;
578        type Red = St::Red;
579    }
580    ///State transition - sets the `green` field to Set
581    pub struct SetGreen<St: State = Empty>(PhantomData<fn() -> St>);
582    impl<St: State> sealed::Sealed for SetGreen<St> {}
583    impl<St: State> State for SetGreen<St> {
584        type Blue = St::Blue;
585        type Green = Set<members::green>;
586        type Red = St::Red;
587    }
588    ///State transition - sets the `red` field to Set
589    pub struct SetRed<St: State = Empty>(PhantomData<fn() -> St>);
590    impl<St: State> sealed::Sealed for SetRed<St> {}
591    impl<St: State> State for SetRed<St> {
592        type Blue = St::Blue;
593        type Green = St::Green;
594        type Red = Set<members::red>;
595    }
596    /// Marker types for field names
597    #[allow(non_camel_case_types)]
598    pub mod members {
599        ///Marker type for the `blue` field
600        pub struct blue(());
601        ///Marker type for the `green` field
602        pub struct green(());
603        ///Marker type for the `red` field
604        pub struct red(());
605    }
606}
607
608/// Builder for constructing an instance of this type.
609pub struct ColorBuilder<St: color_state::State, S: BosStr = DefaultStr> {
610    _state: PhantomData<fn() -> St>,
611    _fields: (Option<i64>, Option<i64>, Option<i64>),
612    _type: PhantomData<fn() -> S>,
613}
614
615impl Color<DefaultStr> {
616    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
617    pub fn new() -> ColorBuilder<color_state::Empty, DefaultStr> {
618        ColorBuilder::new()
619    }
620}
621
622impl<S: BosStr> Color<S> {
623    /// Create a new builder for this type
624    pub fn builder() -> ColorBuilder<color_state::Empty, S> {
625        ColorBuilder::builder()
626    }
627}
628
629impl ColorBuilder<color_state::Empty, DefaultStr> {
630    /// Create a new builder with all fields unset, using the default string type, if needed
631    pub fn new() -> Self {
632        ColorBuilder {
633            _state: PhantomData,
634            _fields: (None, None, None),
635            _type: PhantomData,
636        }
637    }
638}
639
640impl<S: BosStr> ColorBuilder<color_state::Empty, S> {
641    /// Create a new builder with all fields unset
642    pub fn builder() -> Self {
643        ColorBuilder {
644            _state: PhantomData,
645            _fields: (None, None, None),
646            _type: PhantomData,
647        }
648    }
649}
650
651impl<St, S: BosStr> ColorBuilder<St, S>
652where
653    St: color_state::State,
654    St::Blue: color_state::IsUnset,
655{
656    /// Set the `blue` field (required)
657    pub fn blue(
658        mut self,
659        value: impl Into<i64>,
660    ) -> ColorBuilder<color_state::SetBlue<St>, S> {
661        self._fields.0 = Option::Some(value.into());
662        ColorBuilder {
663            _state: PhantomData,
664            _fields: self._fields,
665            _type: PhantomData,
666        }
667    }
668}
669
670impl<St, S: BosStr> ColorBuilder<St, S>
671where
672    St: color_state::State,
673    St::Green: color_state::IsUnset,
674{
675    /// Set the `green` field (required)
676    pub fn green(
677        mut self,
678        value: impl Into<i64>,
679    ) -> ColorBuilder<color_state::SetGreen<St>, S> {
680        self._fields.1 = Option::Some(value.into());
681        ColorBuilder {
682            _state: PhantomData,
683            _fields: self._fields,
684            _type: PhantomData,
685        }
686    }
687}
688
689impl<St, S: BosStr> ColorBuilder<St, S>
690where
691    St: color_state::State,
692    St::Red: color_state::IsUnset,
693{
694    /// Set the `red` field (required)
695    pub fn red(
696        mut self,
697        value: impl Into<i64>,
698    ) -> ColorBuilder<color_state::SetRed<St>, S> {
699        self._fields.2 = Option::Some(value.into());
700        ColorBuilder {
701            _state: PhantomData,
702            _fields: self._fields,
703            _type: PhantomData,
704        }
705    }
706}
707
708impl<St, S: BosStr> ColorBuilder<St, S>
709where
710    St: color_state::State,
711    St::Blue: color_state::IsSet,
712    St::Green: color_state::IsSet,
713    St::Red: color_state::IsSet,
714{
715    /// Build the final struct.
716    pub fn build(self) -> Color<S> {
717        Color {
718            blue: self._fields.0.unwrap(),
719            green: self._fields.1.unwrap(),
720            red: self._fields.2.unwrap(),
721            extra_data: Default::default(),
722        }
723    }
724    /// Build the final struct with custom extra_data.
725    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Color<S> {
726        Color {
727            blue: self._fields.0.unwrap(),
728            green: self._fields.1.unwrap(),
729            red: self._fields.2.unwrap(),
730            extra_data: Some(extra_data),
731        }
732    }
733}
734
735pub mod profile_state {
736
737    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
738    #[allow(unused)]
739    use ::core::marker::PhantomData;
740    mod sealed {
741        pub trait Sealed {}
742    }
743    /// State trait tracking which required fields have been set
744    pub trait State: sealed::Sealed {}
745    /// Empty state - all required fields are unset
746    pub struct Empty(());
747    impl sealed::Sealed for Empty {}
748    impl State for Empty {}
749    /// Marker types for field names
750    #[allow(non_camel_case_types)]
751    pub mod members {}
752}
753
754/// Builder for constructing an instance of this type.
755pub struct ProfileBuilder<St: profile_state::State, S: BosStr = DefaultStr> {
756    _state: PhantomData<fn() -> St>,
757    _fields: (
758        Option<profile::BadgeSelections<S>>,
759        Option<profile::Color<S>>,
760        Option<Vec<profile::SelfLabel<S>>>,
761    ),
762    _type: PhantomData<fn() -> S>,
763}
764
765impl Profile<DefaultStr> {
766    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
767    pub fn new() -> ProfileBuilder<profile_state::Empty, DefaultStr> {
768        ProfileBuilder::new()
769    }
770}
771
772impl<S: BosStr> Profile<S> {
773    /// Create a new builder for this type
774    pub fn builder() -> ProfileBuilder<profile_state::Empty, S> {
775        ProfileBuilder::builder()
776    }
777}
778
779impl ProfileBuilder<profile_state::Empty, DefaultStr> {
780    /// Create a new builder with all fields unset, using the default string type, if needed
781    pub fn new() -> Self {
782        ProfileBuilder {
783            _state: PhantomData,
784            _fields: (None, None, None),
785            _type: PhantomData,
786        }
787    }
788}
789
790impl<S: BosStr> ProfileBuilder<profile_state::Empty, S> {
791    /// Create a new builder with all fields unset
792    pub fn builder() -> Self {
793        ProfileBuilder {
794            _state: PhantomData,
795            _fields: (None, None, None),
796            _type: PhantomData,
797        }
798    }
799}
800
801impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
802    /// Set the `badges` field (optional)
803    pub fn badges(
804        mut self,
805        value: impl Into<Option<profile::BadgeSelections<S>>>,
806    ) -> Self {
807        self._fields.0 = value.into();
808        self
809    }
810    /// Set the `badges` field to an Option value (optional)
811    pub fn maybe_badges(mut self, value: Option<profile::BadgeSelections<S>>) -> Self {
812        self._fields.0 = value;
813        self
814    }
815}
816
817impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
818    /// Set the `color` field (optional)
819    pub fn color(mut self, value: impl Into<Option<profile::Color<S>>>) -> Self {
820        self._fields.1 = value.into();
821        self
822    }
823    /// Set the `color` field to an Option value (optional)
824    pub fn maybe_color(mut self, value: Option<profile::Color<S>>) -> Self {
825        self._fields.1 = value;
826        self
827    }
828}
829
830impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
831    /// Set the `selfLabels` field (optional)
832    pub fn self_labels(
833        mut self,
834        value: impl Into<Option<Vec<profile::SelfLabel<S>>>>,
835    ) -> Self {
836        self._fields.2 = value.into();
837        self
838    }
839    /// Set the `selfLabels` field to an Option value (optional)
840    pub fn maybe_self_labels(
841        mut self,
842        value: Option<Vec<profile::SelfLabel<S>>>,
843    ) -> Self {
844        self._fields.2 = value;
845        self
846    }
847}
848
849impl<St, S: BosStr> ProfileBuilder<St, S>
850where
851    St: profile_state::State,
852{
853    /// Build the final struct.
854    pub fn build(self) -> Profile<S> {
855        Profile {
856            badges: self._fields.0,
857            color: self._fields.1,
858            self_labels: self._fields.2,
859            extra_data: Default::default(),
860        }
861    }
862    /// Build the final struct with custom extra_data.
863    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Profile<S> {
864        Profile {
865            badges: self._fields.0,
866            color: self._fields.1,
867            self_labels: self._fields.2,
868            extra_data: Some(extra_data),
869        }
870    }
871}
872
873pub mod streamer_badge_selection_state {
874
875    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
876    #[allow(unused)]
877    use ::core::marker::PhantomData;
878    mod sealed {
879        pub trait Sealed {}
880    }
881    /// State trait tracking which required fields have been set
882    pub trait State: sealed::Sealed {
883        type Badge;
884        type Streamer;
885    }
886    /// Empty state - all required fields are unset
887    pub struct Empty(());
888    impl sealed::Sealed for Empty {}
889    impl State for Empty {
890        type Badge = Unset;
891        type Streamer = Unset;
892    }
893    ///State transition - sets the `badge` field to Set
894    pub struct SetBadge<St: State = Empty>(PhantomData<fn() -> St>);
895    impl<St: State> sealed::Sealed for SetBadge<St> {}
896    impl<St: State> State for SetBadge<St> {
897        type Badge = Set<members::badge>;
898        type Streamer = St::Streamer;
899    }
900    ///State transition - sets the `streamer` field to Set
901    pub struct SetStreamer<St: State = Empty>(PhantomData<fn() -> St>);
902    impl<St: State> sealed::Sealed for SetStreamer<St> {}
903    impl<St: State> State for SetStreamer<St> {
904        type Badge = St::Badge;
905        type Streamer = Set<members::streamer>;
906    }
907    /// Marker types for field names
908    #[allow(non_camel_case_types)]
909    pub mod members {
910        ///Marker type for the `badge` field
911        pub struct badge(());
912        ///Marker type for the `streamer` field
913        pub struct streamer(());
914    }
915}
916
917/// Builder for constructing an instance of this type.
918pub struct StreamerBadgeSelectionBuilder<
919    St: streamer_badge_selection_state::State,
920    S: BosStr = DefaultStr,
921> {
922    _state: PhantomData<fn() -> St>,
923    _fields: (Option<StrongRef<S>>, Option<Did<S>>),
924    _type: PhantomData<fn() -> S>,
925}
926
927impl StreamerBadgeSelection<DefaultStr> {
928    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
929    pub fn new() -> StreamerBadgeSelectionBuilder<
930        streamer_badge_selection_state::Empty,
931        DefaultStr,
932    > {
933        StreamerBadgeSelectionBuilder::new()
934    }
935}
936
937impl<S: BosStr> StreamerBadgeSelection<S> {
938    /// Create a new builder for this type
939    pub fn builder() -> StreamerBadgeSelectionBuilder<
940        streamer_badge_selection_state::Empty,
941        S,
942    > {
943        StreamerBadgeSelectionBuilder::builder()
944    }
945}
946
947impl StreamerBadgeSelectionBuilder<streamer_badge_selection_state::Empty, DefaultStr> {
948    /// Create a new builder with all fields unset, using the default string type, if needed
949    pub fn new() -> Self {
950        StreamerBadgeSelectionBuilder {
951            _state: PhantomData,
952            _fields: (None, None),
953            _type: PhantomData,
954        }
955    }
956}
957
958impl<S: BosStr> StreamerBadgeSelectionBuilder<streamer_badge_selection_state::Empty, S> {
959    /// Create a new builder with all fields unset
960    pub fn builder() -> Self {
961        StreamerBadgeSelectionBuilder {
962            _state: PhantomData,
963            _fields: (None, None),
964            _type: PhantomData,
965        }
966    }
967}
968
969impl<St, S: BosStr> StreamerBadgeSelectionBuilder<St, S>
970where
971    St: streamer_badge_selection_state::State,
972    St::Badge: streamer_badge_selection_state::IsUnset,
973{
974    /// Set the `badge` field (required)
975    pub fn badge(
976        mut self,
977        value: impl Into<StrongRef<S>>,
978    ) -> StreamerBadgeSelectionBuilder<streamer_badge_selection_state::SetBadge<St>, S> {
979        self._fields.0 = Option::Some(value.into());
980        StreamerBadgeSelectionBuilder {
981            _state: PhantomData,
982            _fields: self._fields,
983            _type: PhantomData,
984        }
985    }
986}
987
988impl<St, S: BosStr> StreamerBadgeSelectionBuilder<St, S>
989where
990    St: streamer_badge_selection_state::State,
991    St::Streamer: streamer_badge_selection_state::IsUnset,
992{
993    /// Set the `streamer` field (required)
994    pub fn streamer(
995        mut self,
996        value: impl Into<Did<S>>,
997    ) -> StreamerBadgeSelectionBuilder<
998        streamer_badge_selection_state::SetStreamer<St>,
999        S,
1000    > {
1001        self._fields.1 = Option::Some(value.into());
1002        StreamerBadgeSelectionBuilder {
1003            _state: PhantomData,
1004            _fields: self._fields,
1005            _type: PhantomData,
1006        }
1007    }
1008}
1009
1010impl<St, S: BosStr> StreamerBadgeSelectionBuilder<St, S>
1011where
1012    St: streamer_badge_selection_state::State,
1013    St::Badge: streamer_badge_selection_state::IsSet,
1014    St::Streamer: streamer_badge_selection_state::IsSet,
1015{
1016    /// Build the final struct.
1017    pub fn build(self) -> StreamerBadgeSelection<S> {
1018        StreamerBadgeSelection {
1019            badge: self._fields.0.unwrap(),
1020            streamer: self._fields.1.unwrap(),
1021            extra_data: Default::default(),
1022        }
1023    }
1024    /// Build the final struct with custom extra_data.
1025    pub fn build_with_data(
1026        self,
1027        extra_data: BTreeMap<SmolStr, Data<S>>,
1028    ) -> StreamerBadgeSelection<S> {
1029        StreamerBadgeSelection {
1030            badge: self._fields.0.unwrap(),
1031            streamer: self._fields.1.unwrap(),
1032            extra_data: Some(extra_data),
1033        }
1034    }
1035}