Skip to main content

jacquard_api/chat_bsky/
actor.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.actor.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 `chat.bsky.actor` Lexicon namespace/module.
9pub mod declaration;
10pub mod delete_account;
11pub mod export_account_data;
12pub mod get_status;
13
14
15#[allow(unused_imports)]
16use alloc::collections::BTreeMap;
17
18#[allow(unused_imports)]
19use core::marker::PhantomData;
20use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
21
22#[allow(unused_imports)]
23use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
24use jacquard_common::deps::smol_str::SmolStr;
25use jacquard_common::types::string::{Did, Handle, Datetime, UriValue};
26use jacquard_common::types::value::Data;
27use jacquard_derive::{IntoStatic, open_union};
28use jacquard_lexicon::lexicon::LexiconDoc;
29use jacquard_lexicon::schema::LexiconSchema;
30
31#[allow(unused_imports)]
32use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
33use serde::{Serialize, Deserialize};
34use crate::app_bsky::actor::ProfileAssociated;
35use crate::app_bsky::actor::VerificationState;
36use crate::app_bsky::actor::ViewerState;
37use crate::com_atproto::label::Label;
38use crate::chat_bsky::actor;
39/// [NOTE: This is under active development and should be considered unstable while this note is here].
40
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
42#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
43pub struct DirectConvoMember<S: BosStr = DefaultStr> {
44    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
45    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
46}
47
48/// [NOTE: This is under active development and should be considered unstable while this note is here]. A current group convo member.
49
50#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
51#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
52pub struct GroupConvoMember<S: BosStr = DefaultStr> {
53    ///Who added this member. Only present if the member was added (instead of joining via link).
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub added_by: Option<actor::ProfileViewBasic<S>>,
56    ///The member's role within this conversation. Only present in group conversation member lists.
57    pub role: actor::MemberRole<S>,
58    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
59    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
60}
61
62
63#[derive(Debug, Clone, PartialEq, Eq, Hash)]
64pub enum MemberRole<S: BosStr = DefaultStr> {
65    Owner,
66    Standard,
67    Other(S),
68}
69
70impl<S: BosStr> MemberRole<S> {
71    pub fn as_str(&self) -> &str {
72        match self {
73            Self::Owner => "owner",
74            Self::Standard => "standard",
75            Self::Other(s) => s.as_ref(),
76        }
77    }
78    /// Construct from a string-like value, matching known values.
79    pub fn from_value(s: S) -> Self {
80        match s.as_ref() {
81            "owner" => Self::Owner,
82            "standard" => Self::Standard,
83            _ => Self::Other(s),
84        }
85    }
86}
87
88impl<S: BosStr> AsRef<str> for MemberRole<S> {
89    fn as_ref(&self) -> &str {
90        self.as_str()
91    }
92}
93
94impl<S: BosStr> core::fmt::Display for MemberRole<S> {
95    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
96        write!(f, "{}", self.as_str())
97    }
98}
99
100impl<S: BosStr> Serialize for MemberRole<S> {
101    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
102    where
103        Ser: serde::Serializer,
104    {
105        serializer.serialize_str(self.as_str())
106    }
107}
108
109impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for MemberRole<S> {
110    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
111    where
112        D: serde::Deserializer<'de>,
113    {
114        let s = S::deserialize(deserializer)?;
115        Ok(Self::from_value(s))
116    }
117}
118
119impl<S: BosStr> jacquard_common::IntoStatic for MemberRole<S>
120where
121    S: BosStr + jacquard_common::IntoStatic,
122    S::Output: BosStr,
123{
124    type Output = MemberRole<S::Output>;
125    fn into_static(self) -> Self::Output {
126        match self {
127            MemberRole::Owner => MemberRole::Owner,
128            MemberRole::Standard => MemberRole::Standard,
129            MemberRole::Other(v) => MemberRole::Other(v.into_static()),
130        }
131    }
132}
133
134/// [NOTE: This is under active development and should be considered unstable while this note is here]. A past group convo member.
135
136#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
137#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
138pub struct PastGroupConvoMember<S: BosStr = DefaultStr> {
139    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
140    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
141}
142
143
144#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
145#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
146pub struct ProfileViewBasic<S: BosStr = DefaultStr> {
147    #[serde(skip_serializing_if = "Option::is_none")]
148    pub associated: Option<ProfileAssociated<S>>,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub avatar: Option<UriValue<S>>,
151    ///Set to true when the actor cannot actively participate in conversations
152    #[serde(skip_serializing_if = "Option::is_none")]
153    pub chat_disabled: Option<bool>,
154    #[serde(skip_serializing_if = "Option::is_none")]
155    pub created_at: Option<Datetime>,
156    pub did: Did<S>,
157    #[serde(skip_serializing_if = "Option::is_none")]
158    pub display_name: Option<S>,
159    pub handle: Handle<S>,
160    ///Union field that has data specific to different kinds of convos.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub kind: Option<ProfileViewBasicKind<S>>,
163    #[serde(skip_serializing_if = "Option::is_none")]
164    pub labels: Option<Vec<Label<S>>>,
165    #[serde(skip_serializing_if = "Option::is_none")]
166    pub verification: Option<VerificationState<S>>,
167    #[serde(skip_serializing_if = "Option::is_none")]
168    pub viewer: Option<ViewerState<S>>,
169    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
170    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
171}
172
173
174#[open_union]
175#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
176#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
177pub enum ProfileViewBasicKind<S: BosStr = DefaultStr> {
178    #[serde(rename = "chat.bsky.actor.defs#directConvoMember")]
179    DirectConvoMember(Box<actor::DirectConvoMember<S>>),
180    #[serde(rename = "chat.bsky.actor.defs#groupConvoMember")]
181    GroupConvoMember(Box<actor::GroupConvoMember<S>>),
182    #[serde(rename = "chat.bsky.actor.defs#pastGroupConvoMember")]
183    PastGroupConvoMember(Box<actor::PastGroupConvoMember<S>>),
184}
185
186impl<S: BosStr> LexiconSchema for DirectConvoMember<S> {
187    fn nsid() -> &'static str {
188        "chat.bsky.actor.defs"
189    }
190    fn def_name() -> &'static str {
191        "directConvoMember"
192    }
193    fn lexicon_doc() -> LexiconDoc<'static> {
194        lexicon_doc_chat_bsky_actor_defs()
195    }
196    fn validate(&self) -> Result<(), ConstraintError> {
197        Ok(())
198    }
199}
200
201impl<S: BosStr> LexiconSchema for GroupConvoMember<S> {
202    fn nsid() -> &'static str {
203        "chat.bsky.actor.defs"
204    }
205    fn def_name() -> &'static str {
206        "groupConvoMember"
207    }
208    fn lexicon_doc() -> LexiconDoc<'static> {
209        lexicon_doc_chat_bsky_actor_defs()
210    }
211    fn validate(&self) -> Result<(), ConstraintError> {
212        Ok(())
213    }
214}
215
216impl<S: BosStr> LexiconSchema for PastGroupConvoMember<S> {
217    fn nsid() -> &'static str {
218        "chat.bsky.actor.defs"
219    }
220    fn def_name() -> &'static str {
221        "pastGroupConvoMember"
222    }
223    fn lexicon_doc() -> LexiconDoc<'static> {
224        lexicon_doc_chat_bsky_actor_defs()
225    }
226    fn validate(&self) -> Result<(), ConstraintError> {
227        Ok(())
228    }
229}
230
231impl<S: BosStr> LexiconSchema for ProfileViewBasic<S> {
232    fn nsid() -> &'static str {
233        "chat.bsky.actor.defs"
234    }
235    fn def_name() -> &'static str {
236        "profileViewBasic"
237    }
238    fn lexicon_doc() -> LexiconDoc<'static> {
239        lexicon_doc_chat_bsky_actor_defs()
240    }
241    fn validate(&self) -> Result<(), ConstraintError> {
242        if let Some(ref value) = self.display_name {
243            #[allow(unused_comparisons)]
244            if <str>::len(value.as_ref()) > 640usize {
245                return Err(ConstraintError::MaxLength {
246                    path: ValidationPath::from_field("display_name"),
247                    max: 640usize,
248                    actual: <str>::len(value.as_ref()),
249                });
250            }
251        }
252        if let Some(ref value) = self.display_name {
253            {
254                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
255                if count > 64usize {
256                    return Err(ConstraintError::MaxGraphemes {
257                        path: ValidationPath::from_field("display_name"),
258                        max: 64usize,
259                        actual: count,
260                    });
261                }
262            }
263        }
264        Ok(())
265    }
266}
267
268fn lexicon_doc_chat_bsky_actor_defs() -> LexiconDoc<'static> {
269    #[allow(unused_imports)]
270    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
271    use jacquard_lexicon::lexicon::*;
272    use alloc::collections::BTreeMap;
273    LexiconDoc {
274        lexicon: Lexicon::Lexicon1,
275        id: CowStr::new_static("chat.bsky.actor.defs"),
276        defs: {
277            let mut map = BTreeMap::new();
278            map.insert(
279                SmolStr::new_static("directConvoMember"),
280                LexUserType::Object(LexObject {
281                    description: Some(
282                        CowStr::new_static(
283                            "[NOTE: This is under active development and should be considered unstable while this note is here].",
284                        ),
285                    ),
286                    properties: {
287                        #[allow(unused_mut)]
288                        let mut map = BTreeMap::new();
289                        map
290                    },
291                    ..Default::default()
292                }),
293            );
294            map.insert(
295                SmolStr::new_static("groupConvoMember"),
296                LexUserType::Object(LexObject {
297                    description: Some(
298                        CowStr::new_static(
299                            "[NOTE: This is under active development and should be considered unstable while this note is here]. A current group convo member.",
300                        ),
301                    ),
302                    required: Some(vec![SmolStr::new_static("role")]),
303                    properties: {
304                        #[allow(unused_mut)]
305                        let mut map = BTreeMap::new();
306                        map.insert(
307                            SmolStr::new_static("addedBy"),
308                            LexObjectProperty::Ref(LexRef {
309                                r#ref: CowStr::new_static("#profileViewBasic"),
310                                ..Default::default()
311                            }),
312                        );
313                        map.insert(
314                            SmolStr::new_static("role"),
315                            LexObjectProperty::Ref(LexRef {
316                                r#ref: CowStr::new_static("#memberRole"),
317                                ..Default::default()
318                            }),
319                        );
320                        map
321                    },
322                    ..Default::default()
323                }),
324            );
325            map.insert(
326                SmolStr::new_static("memberRole"),
327                LexUserType::String(LexString { ..Default::default() }),
328            );
329            map.insert(
330                SmolStr::new_static("pastGroupConvoMember"),
331                LexUserType::Object(LexObject {
332                    description: Some(
333                        CowStr::new_static(
334                            "[NOTE: This is under active development and should be considered unstable while this note is here]. A past group convo member.",
335                        ),
336                    ),
337                    required: Some(vec![]),
338                    properties: {
339                        #[allow(unused_mut)]
340                        let mut map = BTreeMap::new();
341                        map
342                    },
343                    ..Default::default()
344                }),
345            );
346            map.insert(
347                SmolStr::new_static("profileViewBasic"),
348                LexUserType::Object(LexObject {
349                    required: Some(
350                        vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
351                    ),
352                    properties: {
353                        #[allow(unused_mut)]
354                        let mut map = BTreeMap::new();
355                        map.insert(
356                            SmolStr::new_static("associated"),
357                            LexObjectProperty::Ref(LexRef {
358                                r#ref: CowStr::new_static(
359                                    "app.bsky.actor.defs#profileAssociated",
360                                ),
361                                ..Default::default()
362                            }),
363                        );
364                        map.insert(
365                            SmolStr::new_static("avatar"),
366                            LexObjectProperty::String(LexString {
367                                format: Some(LexStringFormat::Uri),
368                                ..Default::default()
369                            }),
370                        );
371                        map.insert(
372                            SmolStr::new_static("chatDisabled"),
373                            LexObjectProperty::Boolean(LexBoolean {
374                                ..Default::default()
375                            }),
376                        );
377                        map.insert(
378                            SmolStr::new_static("createdAt"),
379                            LexObjectProperty::String(LexString {
380                                format: Some(LexStringFormat::Datetime),
381                                ..Default::default()
382                            }),
383                        );
384                        map.insert(
385                            SmolStr::new_static("did"),
386                            LexObjectProperty::String(LexString {
387                                format: Some(LexStringFormat::Did),
388                                ..Default::default()
389                            }),
390                        );
391                        map.insert(
392                            SmolStr::new_static("displayName"),
393                            LexObjectProperty::String(LexString {
394                                max_length: Some(640usize),
395                                max_graphemes: Some(64usize),
396                                ..Default::default()
397                            }),
398                        );
399                        map.insert(
400                            SmolStr::new_static("handle"),
401                            LexObjectProperty::String(LexString {
402                                format: Some(LexStringFormat::Handle),
403                                ..Default::default()
404                            }),
405                        );
406                        map.insert(
407                            SmolStr::new_static("kind"),
408                            LexObjectProperty::Union(LexRefUnion {
409                                description: Some(
410                                    CowStr::new_static(
411                                        "Union field that has data specific to different kinds of convos.",
412                                    ),
413                                ),
414                                refs: vec![
415                                    CowStr::new_static("#directConvoMember"),
416                                    CowStr::new_static("#groupConvoMember"),
417                                    CowStr::new_static("#pastGroupConvoMember")
418                                ],
419                                ..Default::default()
420                            }),
421                        );
422                        map.insert(
423                            SmolStr::new_static("labels"),
424                            LexObjectProperty::Array(LexArray {
425                                items: LexArrayItem::Ref(LexRef {
426                                    r#ref: CowStr::new_static("com.atproto.label.defs#label"),
427                                    ..Default::default()
428                                }),
429                                ..Default::default()
430                            }),
431                        );
432                        map.insert(
433                            SmolStr::new_static("verification"),
434                            LexObjectProperty::Ref(LexRef {
435                                r#ref: CowStr::new_static(
436                                    "app.bsky.actor.defs#verificationState",
437                                ),
438                                ..Default::default()
439                            }),
440                        );
441                        map.insert(
442                            SmolStr::new_static("viewer"),
443                            LexObjectProperty::Ref(LexRef {
444                                r#ref: CowStr::new_static(
445                                    "app.bsky.actor.defs#viewerState",
446                                ),
447                                ..Default::default()
448                            }),
449                        );
450                        map
451                    },
452                    ..Default::default()
453                }),
454            );
455            map
456        },
457        ..Default::default()
458    }
459}
460
461pub mod group_convo_member_state {
462
463    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
464    #[allow(unused)]
465    use ::core::marker::PhantomData;
466    mod sealed {
467        pub trait Sealed {}
468    }
469    /// State trait tracking which required fields have been set
470    pub trait State: sealed::Sealed {
471        type Role;
472    }
473    /// Empty state - all required fields are unset
474    pub struct Empty(());
475    impl sealed::Sealed for Empty {}
476    impl State for Empty {
477        type Role = Unset;
478    }
479    ///State transition - sets the `role` field to Set
480    pub struct SetRole<St: State = Empty>(PhantomData<fn() -> St>);
481    impl<St: State> sealed::Sealed for SetRole<St> {}
482    impl<St: State> State for SetRole<St> {
483        type Role = Set<members::role>;
484    }
485    /// Marker types for field names
486    #[allow(non_camel_case_types)]
487    pub mod members {
488        ///Marker type for the `role` field
489        pub struct role(());
490    }
491}
492
493/// Builder for constructing an instance of this type.
494pub struct GroupConvoMemberBuilder<
495    St: group_convo_member_state::State,
496    S: BosStr = DefaultStr,
497> {
498    _state: PhantomData<fn() -> St>,
499    _fields: (Option<actor::ProfileViewBasic<S>>, Option<actor::MemberRole<S>>),
500    _type: PhantomData<fn() -> S>,
501}
502
503impl GroupConvoMember<DefaultStr> {
504    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
505    pub fn new() -> GroupConvoMemberBuilder<
506        group_convo_member_state::Empty,
507        DefaultStr,
508    > {
509        GroupConvoMemberBuilder::new()
510    }
511}
512
513impl<S: BosStr> GroupConvoMember<S> {
514    /// Create a new builder for this type
515    pub fn builder() -> GroupConvoMemberBuilder<group_convo_member_state::Empty, S> {
516        GroupConvoMemberBuilder::builder()
517    }
518}
519
520impl GroupConvoMemberBuilder<group_convo_member_state::Empty, DefaultStr> {
521    /// Create a new builder with all fields unset, using the default string type, if needed
522    pub fn new() -> Self {
523        GroupConvoMemberBuilder {
524            _state: PhantomData,
525            _fields: (None, None),
526            _type: PhantomData,
527        }
528    }
529}
530
531impl<S: BosStr> GroupConvoMemberBuilder<group_convo_member_state::Empty, S> {
532    /// Create a new builder with all fields unset
533    pub fn builder() -> Self {
534        GroupConvoMemberBuilder {
535            _state: PhantomData,
536            _fields: (None, None),
537            _type: PhantomData,
538        }
539    }
540}
541
542impl<St: group_convo_member_state::State, S: BosStr> GroupConvoMemberBuilder<St, S> {
543    /// Set the `addedBy` field (optional)
544    pub fn added_by(
545        mut self,
546        value: impl Into<Option<actor::ProfileViewBasic<S>>>,
547    ) -> Self {
548        self._fields.0 = value.into();
549        self
550    }
551    /// Set the `addedBy` field to an Option value (optional)
552    pub fn maybe_added_by(mut self, value: Option<actor::ProfileViewBasic<S>>) -> Self {
553        self._fields.0 = value;
554        self
555    }
556}
557
558impl<St, S: BosStr> GroupConvoMemberBuilder<St, S>
559where
560    St: group_convo_member_state::State,
561    St::Role: group_convo_member_state::IsUnset,
562{
563    /// Set the `role` field (required)
564    pub fn role(
565        mut self,
566        value: impl Into<actor::MemberRole<S>>,
567    ) -> GroupConvoMemberBuilder<group_convo_member_state::SetRole<St>, S> {
568        self._fields.1 = Option::Some(value.into());
569        GroupConvoMemberBuilder {
570            _state: PhantomData,
571            _fields: self._fields,
572            _type: PhantomData,
573        }
574    }
575}
576
577impl<St, S: BosStr> GroupConvoMemberBuilder<St, S>
578where
579    St: group_convo_member_state::State,
580    St::Role: group_convo_member_state::IsSet,
581{
582    /// Build the final struct.
583    pub fn build(self) -> GroupConvoMember<S> {
584        GroupConvoMember {
585            added_by: self._fields.0,
586            role: self._fields.1.unwrap(),
587            extra_data: Default::default(),
588        }
589    }
590    /// Build the final struct with custom extra_data.
591    pub fn build_with_data(
592        self,
593        extra_data: BTreeMap<SmolStr, Data<S>>,
594    ) -> GroupConvoMember<S> {
595        GroupConvoMember {
596            added_by: self._fields.0,
597            role: self._fields.1.unwrap(),
598            extra_data: Some(extra_data),
599        }
600    }
601}
602
603pub mod profile_view_basic_state {
604
605    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
606    #[allow(unused)]
607    use ::core::marker::PhantomData;
608    mod sealed {
609        pub trait Sealed {}
610    }
611    /// State trait tracking which required fields have been set
612    pub trait State: sealed::Sealed {
613        type Did;
614        type Handle;
615    }
616    /// Empty state - all required fields are unset
617    pub struct Empty(());
618    impl sealed::Sealed for Empty {}
619    impl State for Empty {
620        type Did = Unset;
621        type Handle = Unset;
622    }
623    ///State transition - sets the `did` field to Set
624    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
625    impl<St: State> sealed::Sealed for SetDid<St> {}
626    impl<St: State> State for SetDid<St> {
627        type Did = Set<members::did>;
628        type Handle = St::Handle;
629    }
630    ///State transition - sets the `handle` field to Set
631    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
632    impl<St: State> sealed::Sealed for SetHandle<St> {}
633    impl<St: State> State for SetHandle<St> {
634        type Did = St::Did;
635        type Handle = Set<members::handle>;
636    }
637    /// Marker types for field names
638    #[allow(non_camel_case_types)]
639    pub mod members {
640        ///Marker type for the `did` field
641        pub struct did(());
642        ///Marker type for the `handle` field
643        pub struct handle(());
644    }
645}
646
647/// Builder for constructing an instance of this type.
648pub struct ProfileViewBasicBuilder<
649    St: profile_view_basic_state::State,
650    S: BosStr = DefaultStr,
651> {
652    _state: PhantomData<fn() -> St>,
653    _fields: (
654        Option<ProfileAssociated<S>>,
655        Option<UriValue<S>>,
656        Option<bool>,
657        Option<Datetime>,
658        Option<Did<S>>,
659        Option<S>,
660        Option<Handle<S>>,
661        Option<ProfileViewBasicKind<S>>,
662        Option<Vec<Label<S>>>,
663        Option<VerificationState<S>>,
664        Option<ViewerState<S>>,
665    ),
666    _type: PhantomData<fn() -> S>,
667}
668
669impl ProfileViewBasic<DefaultStr> {
670    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
671    pub fn new() -> ProfileViewBasicBuilder<
672        profile_view_basic_state::Empty,
673        DefaultStr,
674    > {
675        ProfileViewBasicBuilder::new()
676    }
677}
678
679impl<S: BosStr> ProfileViewBasic<S> {
680    /// Create a new builder for this type
681    pub fn builder() -> ProfileViewBasicBuilder<profile_view_basic_state::Empty, S> {
682        ProfileViewBasicBuilder::builder()
683    }
684}
685
686impl ProfileViewBasicBuilder<profile_view_basic_state::Empty, DefaultStr> {
687    /// Create a new builder with all fields unset, using the default string type, if needed
688    pub fn new() -> Self {
689        ProfileViewBasicBuilder {
690            _state: PhantomData,
691            _fields: (None, None, None, None, None, None, None, None, None, None, None),
692            _type: PhantomData,
693        }
694    }
695}
696
697impl<S: BosStr> ProfileViewBasicBuilder<profile_view_basic_state::Empty, S> {
698    /// Create a new builder with all fields unset
699    pub fn builder() -> Self {
700        ProfileViewBasicBuilder {
701            _state: PhantomData,
702            _fields: (None, None, None, None, None, None, None, None, None, None, None),
703            _type: PhantomData,
704        }
705    }
706}
707
708impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
709    /// Set the `associated` field (optional)
710    pub fn associated(mut self, value: impl Into<Option<ProfileAssociated<S>>>) -> Self {
711        self._fields.0 = value.into();
712        self
713    }
714    /// Set the `associated` field to an Option value (optional)
715    pub fn maybe_associated(mut self, value: Option<ProfileAssociated<S>>) -> Self {
716        self._fields.0 = value;
717        self
718    }
719}
720
721impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
722    /// Set the `avatar` field (optional)
723    pub fn avatar(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
724        self._fields.1 = value.into();
725        self
726    }
727    /// Set the `avatar` field to an Option value (optional)
728    pub fn maybe_avatar(mut self, value: Option<UriValue<S>>) -> Self {
729        self._fields.1 = value;
730        self
731    }
732}
733
734impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
735    /// Set the `chatDisabled` field (optional)
736    pub fn chat_disabled(mut self, value: impl Into<Option<bool>>) -> Self {
737        self._fields.2 = value.into();
738        self
739    }
740    /// Set the `chatDisabled` field to an Option value (optional)
741    pub fn maybe_chat_disabled(mut self, value: Option<bool>) -> Self {
742        self._fields.2 = value;
743        self
744    }
745}
746
747impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
748    /// Set the `createdAt` field (optional)
749    pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
750        self._fields.3 = value.into();
751        self
752    }
753    /// Set the `createdAt` field to an Option value (optional)
754    pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
755        self._fields.3 = value;
756        self
757    }
758}
759
760impl<St, S: BosStr> ProfileViewBasicBuilder<St, S>
761where
762    St: profile_view_basic_state::State,
763    St::Did: profile_view_basic_state::IsUnset,
764{
765    /// Set the `did` field (required)
766    pub fn did(
767        mut self,
768        value: impl Into<Did<S>>,
769    ) -> ProfileViewBasicBuilder<profile_view_basic_state::SetDid<St>, S> {
770        self._fields.4 = Option::Some(value.into());
771        ProfileViewBasicBuilder {
772            _state: PhantomData,
773            _fields: self._fields,
774            _type: PhantomData,
775        }
776    }
777}
778
779impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
780    /// Set the `displayName` field (optional)
781    pub fn display_name(mut self, value: impl Into<Option<S>>) -> Self {
782        self._fields.5 = value.into();
783        self
784    }
785    /// Set the `displayName` field to an Option value (optional)
786    pub fn maybe_display_name(mut self, value: Option<S>) -> Self {
787        self._fields.5 = value;
788        self
789    }
790}
791
792impl<St, S: BosStr> ProfileViewBasicBuilder<St, S>
793where
794    St: profile_view_basic_state::State,
795    St::Handle: profile_view_basic_state::IsUnset,
796{
797    /// Set the `handle` field (required)
798    pub fn handle(
799        mut self,
800        value: impl Into<Handle<S>>,
801    ) -> ProfileViewBasicBuilder<profile_view_basic_state::SetHandle<St>, S> {
802        self._fields.6 = Option::Some(value.into());
803        ProfileViewBasicBuilder {
804            _state: PhantomData,
805            _fields: self._fields,
806            _type: PhantomData,
807        }
808    }
809}
810
811impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
812    /// Set the `kind` field (optional)
813    pub fn kind(mut self, value: impl Into<Option<ProfileViewBasicKind<S>>>) -> Self {
814        self._fields.7 = value.into();
815        self
816    }
817    /// Set the `kind` field to an Option value (optional)
818    pub fn maybe_kind(mut self, value: Option<ProfileViewBasicKind<S>>) -> Self {
819        self._fields.7 = value;
820        self
821    }
822}
823
824impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
825    /// Set the `labels` field (optional)
826    pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> Self {
827        self._fields.8 = value.into();
828        self
829    }
830    /// Set the `labels` field to an Option value (optional)
831    pub fn maybe_labels(mut self, value: Option<Vec<Label<S>>>) -> Self {
832        self._fields.8 = value;
833        self
834    }
835}
836
837impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
838    /// Set the `verification` field (optional)
839    pub fn verification(
840        mut self,
841        value: impl Into<Option<VerificationState<S>>>,
842    ) -> Self {
843        self._fields.9 = value.into();
844        self
845    }
846    /// Set the `verification` field to an Option value (optional)
847    pub fn maybe_verification(mut self, value: Option<VerificationState<S>>) -> Self {
848        self._fields.9 = value;
849        self
850    }
851}
852
853impl<St: profile_view_basic_state::State, S: BosStr> ProfileViewBasicBuilder<St, S> {
854    /// Set the `viewer` field (optional)
855    pub fn viewer(mut self, value: impl Into<Option<ViewerState<S>>>) -> Self {
856        self._fields.10 = value.into();
857        self
858    }
859    /// Set the `viewer` field to an Option value (optional)
860    pub fn maybe_viewer(mut self, value: Option<ViewerState<S>>) -> Self {
861        self._fields.10 = value;
862        self
863    }
864}
865
866impl<St, S: BosStr> ProfileViewBasicBuilder<St, S>
867where
868    St: profile_view_basic_state::State,
869    St::Did: profile_view_basic_state::IsSet,
870    St::Handle: profile_view_basic_state::IsSet,
871{
872    /// Build the final struct.
873    pub fn build(self) -> ProfileViewBasic<S> {
874        ProfileViewBasic {
875            associated: self._fields.0,
876            avatar: self._fields.1,
877            chat_disabled: self._fields.2,
878            created_at: self._fields.3,
879            did: self._fields.4.unwrap(),
880            display_name: self._fields.5,
881            handle: self._fields.6.unwrap(),
882            kind: self._fields.7,
883            labels: self._fields.8,
884            verification: self._fields.9,
885            viewer: self._fields.10,
886            extra_data: Default::default(),
887        }
888    }
889    /// Build the final struct with custom extra_data.
890    pub fn build_with_data(
891        self,
892        extra_data: BTreeMap<SmolStr, Data<S>>,
893    ) -> ProfileViewBasic<S> {
894        ProfileViewBasic {
895            associated: self._fields.0,
896            avatar: self._fields.1,
897            chat_disabled: self._fields.2,
898            created_at: self._fields.3,
899            did: self._fields.4.unwrap(),
900            display_name: self._fields.5,
901            handle: self._fields.6.unwrap(),
902            kind: self._fields.7,
903            labels: self._fields.8,
904            verification: self._fields.9,
905            viewer: self._fields.10,
906            extra_data: Some(extra_data),
907        }
908    }
909}