// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: social.tophhie.profile
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::social_tophhie::profile;
/// Granular communication consent flags.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CommunicationPreferences<S: BosStr = DefaultStr> {
    ///True if the user consents to receive marketing communications.
    pub marketing: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "social.tophhie.profile",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Profile<S: BosStr = DefaultStr> {
    ///User's opt-in/out preferences for communications.
    pub communication_preferences: profile::CommunicationPreferences<S>,
    ///ISO 8601 timestamp when this profile record was created.
    pub created_at: Datetime,
    ///User's opt-in/out preferences for PDS features.
    pub pds_preferences: profile::PdsPreferences<S>,
    ///ISO 8601 timestamp when this profile record was updated.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<Datetime>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

/// Granular PDS preference consent flags.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PdsPreferences<S: BosStr = DefaultStr> {
    ///True if the user participates in accessibility scoring.
    pub accessibility_scoring: bool,
    ///True if the user is shown on the Tophhie Social homepage.
    pub show_on_homepage: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

impl<S: BosStr> LexiconSchema for CommunicationPreferences<S> {
    fn nsid() -> &'static str {
        "social.tophhie.profile"
    }
    fn def_name() -> &'static str {
        "communicationPreferences"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_tophhie_profile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct ProfileRecord;
impl XrpcResp for ProfileRecord {
    const NSID: &'static str = "social.tophhie.profile";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ProfileGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Profile<S> {
    const NSID: &'static str = "social.tophhie.profile";
    type Record = ProfileRecord;
}

impl Collection for ProfileRecord {
    const NSID: &'static str = "social.tophhie.profile";
    type Record = ProfileRecord;
}

impl<S: BosStr> LexiconSchema for Profile<S> {
    fn nsid() -> &'static str {
        "social.tophhie.profile"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_tophhie_profile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PdsPreferences<S> {
    fn nsid() -> &'static str {
        "social.tophhie.profile"
    }
    fn def_name() -> &'static str {
        "pdsPreferences"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_tophhie_profile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod communication_preferences_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Marketing;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Marketing = Unset;
    }
    ///State transition - sets the `marketing` field to Set
    pub struct SetMarketing<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMarketing<St> {}
    impl<St: State> State for SetMarketing<St> {
        type Marketing = Set<members::marketing>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `marketing` field
        pub struct marketing(());
    }
}

/// Builder for constructing an instance of this type.
pub struct CommunicationPreferencesBuilder<
    St: communication_preferences_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<bool>,),
    _type: PhantomData<fn() -> S>,
}

impl CommunicationPreferences<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> CommunicationPreferencesBuilder<
        communication_preferences_state::Empty,
        DefaultStr,
    > {
        CommunicationPreferencesBuilder::new()
    }
}

impl<S: BosStr> CommunicationPreferences<S> {
    /// Create a new builder for this type
    pub fn builder() -> CommunicationPreferencesBuilder<
        communication_preferences_state::Empty,
        S,
    > {
        CommunicationPreferencesBuilder::builder()
    }
}

impl CommunicationPreferencesBuilder<
    communication_preferences_state::Empty,
    DefaultStr,
> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        CommunicationPreferencesBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> CommunicationPreferencesBuilder<St, S>
where
    St: communication_preferences_state::State,
    St::Marketing: communication_preferences_state::IsUnset,
{
    /// Set the `marketing` field (required)
    pub fn marketing(
        mut self,
        value: impl Into<bool>,
    ) -> CommunicationPreferencesBuilder<
        communication_preferences_state::SetMarketing<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        CommunicationPreferencesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CommunicationPreferencesBuilder<St, S>
where
    St: communication_preferences_state::State,
    St::Marketing: communication_preferences_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CommunicationPreferences<S> {
        CommunicationPreferences {
            marketing: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> CommunicationPreferences<S> {
        CommunicationPreferences {
            marketing: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_social_tophhie_profile() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("social.tophhie.profile"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("communicationPreferences"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Granular communication consent flags."),
                    ),
                    required: Some(vec![SmolStr::new_static("marketing")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("marketing"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    key: Some(CowStr::new_static("literal:self")),
                    record: LexRecordRecord::Object(LexObject {
                        description: Some(CowStr::new_static("Tophhie profile record")),
                        required: Some(
                            vec![
                                SmolStr::new_static("createdAt"),
                                SmolStr::new_static("pdsPreferences"),
                                SmolStr::new_static("communicationPreferences")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("communicationPreferences"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#communicationPreferences"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "ISO 8601 timestamp when this profile record was created.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("pdsPreferences"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#pdsPreferences"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("updatedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "ISO 8601 timestamp when this profile record was updated.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pdsPreferences"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Granular PDS preference consent flags."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("showOnHomepage"),
                            SmolStr::new_static("accessibilityScoring")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("accessibilityScoring"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("showOnHomepage"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod profile_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CommunicationPreferences;
        type CreatedAt;
        type PdsPreferences;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CommunicationPreferences = Unset;
        type CreatedAt = Unset;
        type PdsPreferences = Unset;
    }
    ///State transition - sets the `communication_preferences` field to Set
    pub struct SetCommunicationPreferences<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCommunicationPreferences<St> {}
    impl<St: State> State for SetCommunicationPreferences<St> {
        type CommunicationPreferences = Set<members::communication_preferences>;
        type CreatedAt = St::CreatedAt;
        type PdsPreferences = St::PdsPreferences;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CommunicationPreferences = St::CommunicationPreferences;
        type CreatedAt = Set<members::created_at>;
        type PdsPreferences = St::PdsPreferences;
    }
    ///State transition - sets the `pds_preferences` field to Set
    pub struct SetPdsPreferences<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPdsPreferences<St> {}
    impl<St: State> State for SetPdsPreferences<St> {
        type CommunicationPreferences = St::CommunicationPreferences;
        type CreatedAt = St::CreatedAt;
        type PdsPreferences = Set<members::pds_preferences>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `communication_preferences` field
        pub struct communication_preferences(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `pds_preferences` field
        pub struct pds_preferences(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ProfileBuilder<St: profile_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<profile::CommunicationPreferences<S>>,
        Option<Datetime>,
        Option<profile::PdsPreferences<S>>,
        Option<Datetime>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Profile<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> ProfileBuilder<profile_state::Empty, DefaultStr> {
        ProfileBuilder::new()
    }
}

impl<S: BosStr> Profile<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProfileBuilder<profile_state::Empty, S> {
        ProfileBuilder::builder()
    }
}

impl ProfileBuilder<profile_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        ProfileBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::CommunicationPreferences: profile_state::IsUnset,
{
    /// Set the `communicationPreferences` field (required)
    pub fn communication_preferences(
        mut self,
        value: impl Into<profile::CommunicationPreferences<S>>,
    ) -> ProfileBuilder<profile_state::SetCommunicationPreferences<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::CreatedAt: profile_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> ProfileBuilder<profile_state::SetCreatedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::PdsPreferences: profile_state::IsUnset,
{
    /// Set the `pdsPreferences` field (required)
    pub fn pds_preferences(
        mut self,
        value: impl Into<profile::PdsPreferences<S>>,
    ) -> ProfileBuilder<profile_state::SetPdsPreferences<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `updatedAt` field (optional)
    pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `updatedAt` field to an Option value (optional)
    pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::CommunicationPreferences: profile_state::IsSet,
    St::CreatedAt: profile_state::IsSet,
    St::PdsPreferences: profile_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Profile<S> {
        Profile {
            communication_preferences: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            pds_preferences: self._fields.2.unwrap(),
            updated_at: self._fields.3,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Profile<S> {
        Profile {
            communication_preferences: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            pds_preferences: self._fields.2.unwrap(),
            updated_at: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

pub mod pds_preferences_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type AccessibilityScoring;
        type ShowOnHomepage;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AccessibilityScoring = Unset;
        type ShowOnHomepage = Unset;
    }
    ///State transition - sets the `accessibility_scoring` field to Set
    pub struct SetAccessibilityScoring<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAccessibilityScoring<St> {}
    impl<St: State> State for SetAccessibilityScoring<St> {
        type AccessibilityScoring = Set<members::accessibility_scoring>;
        type ShowOnHomepage = St::ShowOnHomepage;
    }
    ///State transition - sets the `show_on_homepage` field to Set
    pub struct SetShowOnHomepage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetShowOnHomepage<St> {}
    impl<St: State> State for SetShowOnHomepage<St> {
        type AccessibilityScoring = St::AccessibilityScoring;
        type ShowOnHomepage = Set<members::show_on_homepage>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `accessibility_scoring` field
        pub struct accessibility_scoring(());
        ///Marker type for the `show_on_homepage` field
        pub struct show_on_homepage(());
    }
}

/// Builder for constructing an instance of this type.
pub struct PdsPreferencesBuilder<
    St: pds_preferences_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<bool>, Option<bool>),
    _type: PhantomData<fn() -> S>,
}

impl PdsPreferences<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> PdsPreferencesBuilder<pds_preferences_state::Empty, DefaultStr> {
        PdsPreferencesBuilder::new()
    }
}

impl<S: BosStr> PdsPreferences<S> {
    /// Create a new builder for this type
    pub fn builder() -> PdsPreferencesBuilder<pds_preferences_state::Empty, S> {
        PdsPreferencesBuilder::builder()
    }
}

impl PdsPreferencesBuilder<pds_preferences_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        PdsPreferencesBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> PdsPreferencesBuilder<St, S>
where
    St: pds_preferences_state::State,
    St::AccessibilityScoring: pds_preferences_state::IsUnset,
{
    /// Set the `accessibilityScoring` field (required)
    pub fn accessibility_scoring(
        mut self,
        value: impl Into<bool>,
    ) -> PdsPreferencesBuilder<pds_preferences_state::SetAccessibilityScoring<St>, S> {
        self._fields.0 = Option::Some(value.into());
        PdsPreferencesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PdsPreferencesBuilder<St, S>
where
    St: pds_preferences_state::State,
    St::ShowOnHomepage: pds_preferences_state::IsUnset,
{
    /// Set the `showOnHomepage` field (required)
    pub fn show_on_homepage(
        mut self,
        value: impl Into<bool>,
    ) -> PdsPreferencesBuilder<pds_preferences_state::SetShowOnHomepage<St>, S> {
        self._fields.1 = Option::Some(value.into());
        PdsPreferencesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PdsPreferencesBuilder<St, S>
where
    St: pds_preferences_state::State,
    St::AccessibilityScoring: pds_preferences_state::IsSet,
    St::ShowOnHomepage: pds_preferences_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> PdsPreferences<S> {
        PdsPreferences {
            accessibility_scoring: self._fields.0.unwrap(),
            show_on_homepage: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> PdsPreferences<S> {
        PdsPreferences {
            accessibility_scoring: self._fields.0.unwrap(),
            show_on_homepage: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}