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

//! Generated bindings for the `com.atproto.label` Lexicon namespace/module.
pub mod query_labels;


#[cfg(feature = "streaming")]
pub mod subscribe_labels;


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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Cid, Datetime, Language, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::com_atproto::label;
/// Metadata tag on an atproto resource (eg, repo or record).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Label<S: BosStr = DefaultStr> {
    ///Optionally, CID specifying the specific version of 'uri' resource this label applies to.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    ///Timestamp when this label was created.
    pub cts: Datetime,
    ///Timestamp at which this label expires (no longer applies).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exp: Option<Datetime>,
    ///If true, this is a negation label, overwriting a previous label.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub neg: Option<bool>,
    ///Signature of dag-cbor encoded label.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
    pub sig: Option<Bytes>,
    ///DID of the actor who created this label.
    pub src: Did<S>,
    ///AT URI of the record, repository (account), or other resource that this label applies to.
    pub uri: UriValue<S>,
    ///The short string name of the value or type of this label.
    pub val: S,
    ///The AT Protocol version of the label object.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ver: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValue<S: BosStr = DefaultStr> {
    Hide,
    Warn,
    NoUnauthenticated,
    Porn,
    Sexual,
    Nudity,
    GraphicMedia,
    Bot,
    Other(S),
}

impl<S: BosStr> LabelValue<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Hide => "!hide",
            Self::Warn => "!warn",
            Self::NoUnauthenticated => "!no-unauthenticated",
            Self::Porn => "porn",
            Self::Sexual => "sexual",
            Self::Nudity => "nudity",
            Self::GraphicMedia => "graphic-media",
            Self::Bot => "bot",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "!hide" => Self::Hide,
            "!warn" => Self::Warn,
            "!no-unauthenticated" => Self::NoUnauthenticated,
            "porn" => Self::Porn,
            "sexual" => Self::Sexual,
            "nudity" => Self::Nudity,
            "graphic-media" => Self::GraphicMedia,
            "bot" => Self::Bot,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> AsRef<str> for LabelValue<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> core::fmt::Display for LabelValue<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> Serialize for LabelValue<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for LabelValue<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for LabelValue<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = LabelValue<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            LabelValue::Hide => LabelValue::Hide,
            LabelValue::Warn => LabelValue::Warn,
            LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
            LabelValue::Porn => LabelValue::Porn,
            LabelValue::Sexual => LabelValue::Sexual,
            LabelValue::Nudity => LabelValue::Nudity,
            LabelValue::GraphicMedia => LabelValue::GraphicMedia,
            LabelValue::Bot => LabelValue::Bot,
            LabelValue::Other(v) => LabelValue::Other(v.into_static()),
        }
    }
}

/// Declares a label value and its expected interpretations and behaviors.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelValueDefinition<S: BosStr = DefaultStr> {
    ///Does the user need to have adult content enabled in order to configure this label?
    #[serde(skip_serializing_if = "Option::is_none")]
    pub adult_only: Option<bool>,
    ///What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
    pub blurs: LabelValueDefinitionBlurs<S>,
    ///The default setting for this label.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default_setting: Option<LabelValueDefinitionDefaultSetting<S>>,
    ///The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
    pub identifier: S,
    pub locales: Vec<label::LabelValueDefinitionStrings<S>>,
    ///How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
    pub severity: LabelValueDefinitionSeverity<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionBlurs<S: BosStr = DefaultStr> {
    Content,
    Media,
    None,
    Other(S),
}

impl<S: BosStr> LabelValueDefinitionBlurs<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Content => "content",
            Self::Media => "media",
            Self::None => "none",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "content" => Self::Content,
            "media" => Self::Media,
            "none" => Self::None,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for LabelValueDefinitionBlurs<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for LabelValueDefinitionBlurs<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for LabelValueDefinitionBlurs<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionBlurs<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for LabelValueDefinitionBlurs<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionBlurs<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = LabelValueDefinitionBlurs<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content,
            LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media,
            LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None,
            LabelValueDefinitionBlurs::Other(v) => {
                LabelValueDefinitionBlurs::Other(v.into_static())
            }
        }
    }
}

/// The default setting for this label.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionDefaultSetting<S: BosStr = DefaultStr> {
    Ignore,
    Warn,
    Hide,
    Other(S),
}

impl<S: BosStr> LabelValueDefinitionDefaultSetting<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ignore => "ignore",
            Self::Warn => "warn",
            Self::Hide => "hide",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "ignore" => Self::Ignore,
            "warn" => Self::Warn,
            "hide" => Self::Hide,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for LabelValueDefinitionDefaultSetting<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for LabelValueDefinitionDefaultSetting<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for LabelValueDefinitionDefaultSetting<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionDefaultSetting<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for LabelValueDefinitionDefaultSetting<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = LabelValueDefinitionDefaultSetting<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            LabelValueDefinitionDefaultSetting::Ignore => {
                LabelValueDefinitionDefaultSetting::Ignore
            }
            LabelValueDefinitionDefaultSetting::Warn => {
                LabelValueDefinitionDefaultSetting::Warn
            }
            LabelValueDefinitionDefaultSetting::Hide => {
                LabelValueDefinitionDefaultSetting::Hide
            }
            LabelValueDefinitionDefaultSetting::Other(v) => {
                LabelValueDefinitionDefaultSetting::Other(v.into_static())
            }
        }
    }
}

/// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionSeverity<S: BosStr = DefaultStr> {
    Inform,
    Alert,
    None,
    Other(S),
}

impl<S: BosStr> LabelValueDefinitionSeverity<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Inform => "inform",
            Self::Alert => "alert",
            Self::None => "none",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "inform" => Self::Inform,
            "alert" => Self::Alert,
            "none" => Self::None,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for LabelValueDefinitionSeverity<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for LabelValueDefinitionSeverity<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for LabelValueDefinitionSeverity<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionSeverity<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for LabelValueDefinitionSeverity<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionSeverity<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = LabelValueDefinitionSeverity<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform,
            LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert,
            LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None,
            LabelValueDefinitionSeverity::Other(v) => {
                LabelValueDefinitionSeverity::Other(v.into_static())
            }
        }
    }
}

/// Strings which describe the label in the UI, localized into a specific language.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelValueDefinitionStrings<S: BosStr = DefaultStr> {
    ///A longer description of what the label means and why it might be applied.
    pub description: S,
    ///The code of the language these strings are written in.
    pub lang: Language,
    ///A short human-readable name for the label.
    pub name: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SelfLabel<S: BosStr = DefaultStr> {
    ///The short string name of the value or type of this label.
    pub val: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Metadata tags on an atproto record, published by the author within the record.

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

impl<S: BosStr> LexiconSchema for Label<S> {
    fn nsid() -> &'static str {
        "com.atproto.label.defs"
    }
    fn def_name() -> &'static str {
        "label"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_label_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.val;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("val"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LabelValueDefinition<S> {
    fn nsid() -> &'static str {
        "com.atproto.label.defs"
    }
    fn def_name() -> &'static str {
        "labelValueDefinition"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_label_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.identifier;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("identifier"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.identifier;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 100usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("identifier"),
                        max: 100usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LabelValueDefinitionStrings<S> {
    fn nsid() -> &'static str {
        "com.atproto.label.defs"
    }
    fn def_name() -> &'static str {
        "labelValueDefinitionStrings"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_label_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.description;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 100000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.description;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 10000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("description"),
                        max: 10000usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 640usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 640usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SelfLabel<S> {
    fn nsid() -> &'static str {
        "com.atproto.label.defs"
    }
    fn def_name() -> &'static str {
        "selfLabel"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_label_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.val;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("val"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SelfLabels<S> {
    fn nsid() -> &'static str {
        "com.atproto.label.defs"
    }
    fn def_name() -> &'static str {
        "selfLabels"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_atproto_label_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.values;
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("values"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

pub mod label_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 Cts;
        type Src;
        type Uri;
        type Val;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cts = Unset;
        type Src = Unset;
        type Uri = Unset;
        type Val = Unset;
    }
    ///State transition - sets the `cts` field to Set
    pub struct SetCts<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCts<St> {}
    impl<St: State> State for SetCts<St> {
        type Cts = Set<members::cts>;
        type Src = St::Src;
        type Uri = St::Uri;
        type Val = St::Val;
    }
    ///State transition - sets the `src` field to Set
    pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSrc<St> {}
    impl<St: State> State for SetSrc<St> {
        type Cts = St::Cts;
        type Src = Set<members::src>;
        type Uri = St::Uri;
        type Val = St::Val;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Cts = St::Cts;
        type Src = St::Src;
        type Uri = Set<members::uri>;
        type Val = St::Val;
    }
    ///State transition - sets the `val` field to Set
    pub struct SetVal<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetVal<St> {}
    impl<St: State> State for SetVal<St> {
        type Cts = St::Cts;
        type Src = St::Src;
        type Uri = St::Uri;
        type Val = Set<members::val>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cts` field
        pub struct cts(());
        ///Marker type for the `src` field
        pub struct src(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `val` field
        pub struct val(());
    }
}

/// Builder for constructing an instance of this type.
pub struct LabelBuilder<St: label_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Cid<S>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<bool>,
        Option<Bytes>,
        Option<Did<S>>,
        Option<UriValue<S>>,
        Option<S>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Label<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelBuilder<label_state::Empty, S> {
        LabelBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LabelBuilder<St, S>
where
    St: label_state::State,
    St::Cts: label_state::IsUnset,
{
    /// Set the `cts` field (required)
    pub fn cts(
        mut self,
        value: impl Into<Datetime>,
    ) -> LabelBuilder<label_state::SetCts<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LabelBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
    /// Set the `exp` field (optional)
    pub fn exp(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `exp` field to an Option value (optional)
    pub fn maybe_exp(mut self, value: Option<Datetime>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
    /// Set the `neg` field (optional)
    pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `neg` field to an Option value (optional)
    pub fn maybe_neg(mut self, value: Option<bool>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
    /// Set the `sig` field (optional)
    pub fn sig(mut self, value: impl Into<Option<Bytes>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `sig` field to an Option value (optional)
    pub fn maybe_sig(mut self, value: Option<Bytes>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> LabelBuilder<St, S>
where
    St: label_state::State,
    St::Src: label_state::IsUnset,
{
    /// Set the `src` field (required)
    pub fn src(
        mut self,
        value: impl Into<Did<S>>,
    ) -> LabelBuilder<label_state::SetSrc<St>, S> {
        self._fields.5 = Option::Some(value.into());
        LabelBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelBuilder<St, S>
where
    St: label_state::State,
    St::Uri: label_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> LabelBuilder<label_state::SetUri<St>, S> {
        self._fields.6 = Option::Some(value.into());
        LabelBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelBuilder<St, S>
where
    St: label_state::State,
    St::Val: label_state::IsUnset,
{
    /// Set the `val` field (required)
    pub fn val(
        mut self,
        value: impl Into<S>,
    ) -> LabelBuilder<label_state::SetVal<St>, S> {
        self._fields.7 = Option::Some(value.into());
        LabelBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: label_state::State, S: BosStr> LabelBuilder<St, S> {
    /// Set the `ver` field (optional)
    pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `ver` field to an Option value (optional)
    pub fn maybe_ver(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> LabelBuilder<St, S>
where
    St: label_state::State,
    St::Cts: label_state::IsSet,
    St::Src: label_state::IsSet,
    St::Uri: label_state::IsSet,
    St::Val: label_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Label<S> {
        Label {
            cid: self._fields.0,
            cts: self._fields.1.unwrap(),
            exp: self._fields.2,
            neg: self._fields.3,
            sig: self._fields.4,
            src: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            val: self._fields.7.unwrap(),
            ver: self._fields.8,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Label<S> {
        Label {
            cid: self._fields.0,
            cts: self._fields.1.unwrap(),
            exp: self._fields.2,
            neg: self._fields.3,
            sig: self._fields.4,
            src: self._fields.5.unwrap(),
            uri: self._fields.6.unwrap(),
            val: self._fields.7.unwrap(),
            ver: self._fields.8,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_com_atproto_label_defs() -> 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("com.atproto.label.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("label"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Metadata tag on an atproto resource (eg, repo or record).",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("src"), SmolStr::new_static("uri"),
                            SmolStr::new_static("val"), SmolStr::new_static("cts")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Optionally, CID specifying the specific version of 'uri' resource this label applies to.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cts"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Timestamp when this label was created."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("exp"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Timestamp at which this label expires (no longer applies).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("neg"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sig"),
                            LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("src"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "DID of the actor who created this label.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "AT URI of the record, repository (account), or other resource that this label applies to.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("val"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The short string name of the value or type of this label.",
                                    ),
                                ),
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("ver"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("labelValue"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("labelValueDefinition"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Declares a label value and its expected interpretations and behaviors.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("identifier"),
                            SmolStr::new_static("severity"),
                            SmolStr::new_static("blurs"), SmolStr::new_static("locales")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("adultOnly"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("blurs"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("defaultSetting"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The default setting for this label."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("identifier"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
                                    ),
                                ),
                                max_length: Some(100usize),
                                max_graphemes: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("locales"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#labelValueDefinitionStrings"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("severity"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("labelValueDefinitionStrings"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Strings which describe the label in the UI, localized into a specific language.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("lang"), SmolStr::new_static("name"),
                            SmolStr::new_static("description")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "A longer description of what the label means and why it might be applied.",
                                    ),
                                ),
                                max_length: Some(100000usize),
                                max_graphemes: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lang"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The code of the language these strings are written in.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Language),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "A short human-readable name for the label.",
                                    ),
                                ),
                                max_length: Some(640usize),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("selfLabel"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("val")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("val"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The short string name of the value or type of this label.",
                                    ),
                                ),
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("selfLabels"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Metadata tags on an atproto record, published by the author within the record.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("values")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("values"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#selfLabel"),
                                    ..Default::default()
                                }),
                                max_length: Some(10usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod label_value_definition_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 Blurs;
        type Identifier;
        type Locales;
        type Severity;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Blurs = Unset;
        type Identifier = Unset;
        type Locales = Unset;
        type Severity = Unset;
    }
    ///State transition - sets the `blurs` field to Set
    pub struct SetBlurs<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBlurs<St> {}
    impl<St: State> State for SetBlurs<St> {
        type Blurs = Set<members::blurs>;
        type Identifier = St::Identifier;
        type Locales = St::Locales;
        type Severity = St::Severity;
    }
    ///State transition - sets the `identifier` field to Set
    pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIdentifier<St> {}
    impl<St: State> State for SetIdentifier<St> {
        type Blurs = St::Blurs;
        type Identifier = Set<members::identifier>;
        type Locales = St::Locales;
        type Severity = St::Severity;
    }
    ///State transition - sets the `locales` field to Set
    pub struct SetLocales<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLocales<St> {}
    impl<St: State> State for SetLocales<St> {
        type Blurs = St::Blurs;
        type Identifier = St::Identifier;
        type Locales = Set<members::locales>;
        type Severity = St::Severity;
    }
    ///State transition - sets the `severity` field to Set
    pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSeverity<St> {}
    impl<St: State> State for SetSeverity<St> {
        type Blurs = St::Blurs;
        type Identifier = St::Identifier;
        type Locales = St::Locales;
        type Severity = Set<members::severity>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `blurs` field
        pub struct blurs(());
        ///Marker type for the `identifier` field
        pub struct identifier(());
        ///Marker type for the `locales` field
        pub struct locales(());
        ///Marker type for the `severity` field
        pub struct severity(());
    }
}

/// Builder for constructing an instance of this type.
pub struct LabelValueDefinitionBuilder<
    St: label_value_definition_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<bool>,
        Option<LabelValueDefinitionBlurs<S>>,
        Option<LabelValueDefinitionDefaultSetting<S>>,
        Option<S>,
        Option<Vec<label::LabelValueDefinitionStrings<S>>>,
        Option<LabelValueDefinitionSeverity<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> LabelValueDefinition<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelValueDefinitionBuilder<
        label_value_definition_state::Empty,
        S,
    > {
        LabelValueDefinitionBuilder::builder()
    }
}

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

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

impl<
    St: label_value_definition_state::State,
    S: BosStr,
> LabelValueDefinitionBuilder<St, S> {
    /// Set the `adultOnly` field (optional)
    pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `adultOnly` field to an Option value (optional)
    pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
where
    St: label_value_definition_state::State,
    St::Blurs: label_value_definition_state::IsUnset,
{
    /// Set the `blurs` field (required)
    pub fn blurs(
        mut self,
        value: impl Into<LabelValueDefinitionBlurs<S>>,
    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetBlurs<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LabelValueDefinitionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<
    St: label_value_definition_state::State,
    S: BosStr,
> LabelValueDefinitionBuilder<St, S> {
    /// Set the `defaultSetting` field (optional)
    pub fn default_setting(
        mut self,
        value: impl Into<Option<LabelValueDefinitionDefaultSetting<S>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `defaultSetting` field to an Option value (optional)
    pub fn maybe_default_setting(
        mut self,
        value: Option<LabelValueDefinitionDefaultSetting<S>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
where
    St: label_value_definition_state::State,
    St::Identifier: label_value_definition_state::IsUnset,
{
    /// Set the `identifier` field (required)
    pub fn identifier(
        mut self,
        value: impl Into<S>,
    ) -> LabelValueDefinitionBuilder<
        label_value_definition_state::SetIdentifier<St>,
        S,
    > {
        self._fields.3 = Option::Some(value.into());
        LabelValueDefinitionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
where
    St: label_value_definition_state::State,
    St::Locales: label_value_definition_state::IsUnset,
{
    /// Set the `locales` field (required)
    pub fn locales(
        mut self,
        value: impl Into<Vec<label::LabelValueDefinitionStrings<S>>>,
    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetLocales<St>, S> {
        self._fields.4 = Option::Some(value.into());
        LabelValueDefinitionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
where
    St: label_value_definition_state::State,
    St::Severity: label_value_definition_state::IsUnset,
{
    /// Set the `severity` field (required)
    pub fn severity(
        mut self,
        value: impl Into<LabelValueDefinitionSeverity<S>>,
    ) -> LabelValueDefinitionBuilder<label_value_definition_state::SetSeverity<St>, S> {
        self._fields.5 = Option::Some(value.into());
        LabelValueDefinitionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionBuilder<St, S>
where
    St: label_value_definition_state::State,
    St::Blurs: label_value_definition_state::IsSet,
    St::Identifier: label_value_definition_state::IsSet,
    St::Locales: label_value_definition_state::IsSet,
    St::Severity: label_value_definition_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LabelValueDefinition<S> {
        LabelValueDefinition {
            adult_only: self._fields.0,
            blurs: self._fields.1.unwrap(),
            default_setting: self._fields.2,
            identifier: self._fields.3.unwrap(),
            locales: self._fields.4.unwrap(),
            severity: self._fields.5.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>>,
    ) -> LabelValueDefinition<S> {
        LabelValueDefinition {
            adult_only: self._fields.0,
            blurs: self._fields.1.unwrap(),
            default_setting: self._fields.2,
            identifier: self._fields.3.unwrap(),
            locales: self._fields.4.unwrap(),
            severity: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod label_value_definition_strings_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 Description;
        type Lang;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Description = Unset;
        type Lang = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `description` field to Set
    pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDescription<St> {}
    impl<St: State> State for SetDescription<St> {
        type Description = Set<members::description>;
        type Lang = St::Lang;
        type Name = St::Name;
    }
    ///State transition - sets the `lang` field to Set
    pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLang<St> {}
    impl<St: State> State for SetLang<St> {
        type Description = St::Description;
        type Lang = Set<members::lang>;
        type Name = St::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Description = St::Description;
        type Lang = St::Lang;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `description` field
        pub struct description(());
        ///Marker type for the `lang` field
        pub struct lang(());
        ///Marker type for the `name` field
        pub struct name(());
    }
}

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

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

impl<S: BosStr> LabelValueDefinitionStrings<S> {
    /// Create a new builder for this type
    pub fn builder() -> LabelValueDefinitionStringsBuilder<
        label_value_definition_strings_state::Empty,
        S,
    > {
        LabelValueDefinitionStringsBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
where
    St: label_value_definition_strings_state::State,
    St::Description: label_value_definition_strings_state::IsUnset,
{
    /// Set the `description` field (required)
    pub fn description(
        mut self,
        value: impl Into<S>,
    ) -> LabelValueDefinitionStringsBuilder<
        label_value_definition_strings_state::SetDescription<St>,
        S,
    > {
        self._fields.0 = Option::Some(value.into());
        LabelValueDefinitionStringsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
where
    St: label_value_definition_strings_state::State,
    St::Lang: label_value_definition_strings_state::IsUnset,
{
    /// Set the `lang` field (required)
    pub fn lang(
        mut self,
        value: impl Into<Language>,
    ) -> LabelValueDefinitionStringsBuilder<
        label_value_definition_strings_state::SetLang<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        LabelValueDefinitionStringsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
where
    St: label_value_definition_strings_state::State,
    St::Name: label_value_definition_strings_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<S>,
    ) -> LabelValueDefinitionStringsBuilder<
        label_value_definition_strings_state::SetName<St>,
        S,
    > {
        self._fields.2 = Option::Some(value.into());
        LabelValueDefinitionStringsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LabelValueDefinitionStringsBuilder<St, S>
where
    St: label_value_definition_strings_state::State,
    St::Description: label_value_definition_strings_state::IsSet,
    St::Lang: label_value_definition_strings_state::IsSet,
    St::Name: label_value_definition_strings_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LabelValueDefinitionStrings<S> {
        LabelValueDefinitionStrings {
            description: self._fields.0.unwrap(),
            lang: self._fields.1.unwrap(),
            name: self._fields.2.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>>,
    ) -> LabelValueDefinitionStrings<S> {
        LabelValueDefinitionStrings {
            description: self._fields.0.unwrap(),
            lang: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> SelfLabels<S> {
    /// Create a new builder for this type
    pub fn builder() -> SelfLabelsBuilder<self_labels_state::Empty, S> {
        SelfLabelsBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SelfLabelsBuilder<St, S>
where
    St: self_labels_state::State,
    St::Values: self_labels_state::IsUnset,
{
    /// Set the `values` field (required)
    pub fn values(
        mut self,
        value: impl Into<Vec<label::SelfLabel<S>>>,
    ) -> SelfLabelsBuilder<self_labels_state::SetValues<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SelfLabelsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SelfLabelsBuilder<St, S>
where
    St: self_labels_state::State,
    St::Values: self_labels_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SelfLabels<S> {
        SelfLabels {
            values: 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>>,
    ) -> SelfLabels<S> {
        SelfLabels {
            values: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}