// @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.

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;
use jacquard_common::deps::bytes::Bytes;

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Label<'a> {
    ///Optionally, CID specifying the specific version of 'uri' resource this label applies to.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    ///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.
    #[serde(borrow)]
    pub src: Did<'a>,
    ///AT URI of the record, repository (account), or other resource that this label applies to.
    #[serde(borrow)]
    pub uri: UriValue<'a>,
    ///The short string name of the value or type of this label.
    #[serde(borrow)]
    pub val: CowStr<'a>,
    ///The AT Protocol version of the label object.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ver: Option<i64>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValue<'a> {
    Hide,
    Warn,
    NoUnauthenticated,
    Porn,
    Sexual,
    Nudity,
    GraphicMedia,
    Bot,
    Other(CowStr<'a>),
}

impl<'a> LabelValue<'a> {
    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(),
        }
    }
}

impl<'a> From<&'a str> for LabelValue<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "!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(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for LabelValue<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "!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(CowStr::from(s)),
        }
    }
}

impl<'a> AsRef<str> for LabelValue<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

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

impl<'de, 'a> serde::Deserialize<'de> for LabelValue<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl jacquard_common::IntoStatic for LabelValue<'_> {
    type Output = LabelValue<'static>;
    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.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LabelValueDefinition<'a> {
    ///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.
    #[serde(borrow)]
    pub blurs: LabelValueDefinitionBlurs<'a>,
    ///The default setting for this label.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub default_setting: Option<LabelValueDefinitionDefaultSetting<'a>>,
    ///The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
    #[serde(borrow)]
    pub identifier: CowStr<'a>,
    #[serde(borrow)]
    pub locales: Vec<label::LabelValueDefinitionStrings<'a>>,
    ///How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
    #[serde(borrow)]
    pub severity: LabelValueDefinitionSeverity<'a>,
}

/// 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<'a> {
    Content,
    Media,
    None,
    Other(CowStr<'a>),
}

impl<'a> LabelValueDefinitionBlurs<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Content => "content",
            Self::Media => "media",
            Self::None => "none",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for LabelValueDefinitionBlurs<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "content" => Self::Content,
            "media" => Self::Media,
            "none" => Self::None,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for LabelValueDefinitionBlurs<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "content" => Self::Content,
            "media" => Self::Media,
            "none" => Self::None,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for LabelValueDefinitionBlurs<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionBlurs<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for LabelValueDefinitionBlurs<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for LabelValueDefinitionBlurs<'_> {
    type Output = LabelValueDefinitionBlurs<'static>;
    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<'a> {
    Ignore,
    Warn,
    Hide,
    Other(CowStr<'a>),
}

impl<'a> LabelValueDefinitionDefaultSetting<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Ignore => "ignore",
            Self::Warn => "warn",
            Self::Hide => "hide",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for LabelValueDefinitionDefaultSetting<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "ignore" => Self::Ignore,
            "warn" => Self::Warn,
            "hide" => Self::Hide,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for LabelValueDefinitionDefaultSetting<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "ignore" => Self::Ignore,
            "warn" => Self::Warn,
            "hide" => Self::Hide,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for LabelValueDefinitionDefaultSetting<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionDefaultSetting<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for LabelValueDefinitionDefaultSetting<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<'_> {
    type Output = LabelValueDefinitionDefaultSetting<'static>;
    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<'a> {
    Inform,
    Alert,
    None,
    Other(CowStr<'a>),
}

impl<'a> LabelValueDefinitionSeverity<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Inform => "inform",
            Self::Alert => "alert",
            Self::None => "none",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for LabelValueDefinitionSeverity<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "inform" => Self::Inform,
            "alert" => Self::Alert,
            "none" => Self::None,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for LabelValueDefinitionSeverity<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "inform" => Self::Inform,
            "alert" => Self::Alert,
            "none" => Self::None,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for LabelValueDefinitionSeverity<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionSeverity<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for LabelValueDefinitionSeverity<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for LabelValueDefinitionSeverity<'_> {
    type Output = LabelValueDefinitionSeverity<'static>;
    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.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LabelValueDefinitionStrings<'a> {
    ///A longer description of what the label means and why it might be applied.
    #[serde(borrow)]
    pub description: CowStr<'a>,
    ///The code of the language these strings are written in.
    pub lang: Language,
    ///A short human-readable name for the label.
    #[serde(borrow)]
    pub name: CowStr<'a>,
}

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SelfLabel<'a> {
    ///The short string name of the value or type of this label.
    #[serde(borrow)]
    pub val: CowStr<'a>,
}

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SelfLabels<'a> {
    #[serde(borrow)]
    pub values: Vec<label::SelfLabel<'a>>,
}

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

/// Builder for constructing an instance of this type
pub struct LabelBuilder<'a, S: label_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Cid<'a>>,
        Option<Datetime>,
        Option<Datetime>,
        Option<bool>,
        Option<Bytes>,
        Option<Did<'a>>,
        Option<UriValue<'a>>,
        Option<CowStr<'a>>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: label_state::State> LabelBuilder<'a, S> {
    /// Set the `cid` field (optional)
    pub fn cid(mut self, value: impl Into<Option<Cid<'a>>>) -> 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<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S: label_state::State> LabelBuilder<'a, 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<'a, S: label_state::State> LabelBuilder<'a, 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<'a, S: label_state::State> LabelBuilder<'a, 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<'a, S> LabelBuilder<'a, S>
where
    S: label_state::State,
    S::Src: label_state::IsUnset,
{
    /// Set the `src` field (required)
    pub fn src(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> LabelBuilder<'a, label_state::SetSrc<S>> {
        self._fields.5 = Option::Some(value.into());
        LabelBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

impl<'a, S: label_state::State> LabelBuilder<'a, 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<'a, S> LabelBuilder<'a, S>
where
    S: label_state::State,
    S::Src: label_state::IsSet,
    S::Val: label_state::IsSet,
    S::Uri: label_state::IsSet,
    S::Cts: label_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Label<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Label<'a> {
        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 Severity;
        type Blurs;
        type Locales;
        type Identifier;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Severity = Unset;
        type Blurs = Unset;
        type Locales = Unset;
        type Identifier = Unset;
    }
    ///State transition - sets the `severity` field to Set
    pub struct SetSeverity<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSeverity<S> {}
    impl<S: State> State for SetSeverity<S> {
        type Severity = Set<members::severity>;
        type Blurs = S::Blurs;
        type Locales = S::Locales;
        type Identifier = S::Identifier;
    }
    ///State transition - sets the `blurs` field to Set
    pub struct SetBlurs<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBlurs<S> {}
    impl<S: State> State for SetBlurs<S> {
        type Severity = S::Severity;
        type Blurs = Set<members::blurs>;
        type Locales = S::Locales;
        type Identifier = S::Identifier;
    }
    ///State transition - sets the `locales` field to Set
    pub struct SetLocales<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLocales<S> {}
    impl<S: State> State for SetLocales<S> {
        type Severity = S::Severity;
        type Blurs = S::Blurs;
        type Locales = Set<members::locales>;
        type Identifier = S::Identifier;
    }
    ///State transition - sets the `identifier` field to Set
    pub struct SetIdentifier<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIdentifier<S> {}
    impl<S: State> State for SetIdentifier<S> {
        type Severity = S::Severity;
        type Blurs = S::Blurs;
        type Locales = S::Locales;
        type Identifier = Set<members::identifier>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `severity` field
        pub struct severity(());
        ///Marker type for the `blurs` field
        pub struct blurs(());
        ///Marker type for the `locales` field
        pub struct locales(());
        ///Marker type for the `identifier` field
        pub struct identifier(());
    }
}

/// Builder for constructing an instance of this type
pub struct LabelValueDefinitionBuilder<'a, S: label_value_definition_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<bool>,
        Option<LabelValueDefinitionBlurs<'a>>,
        Option<LabelValueDefinitionDefaultSetting<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<label::LabelValueDefinitionStrings<'a>>>,
        Option<LabelValueDefinitionSeverity<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, 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<'a, S> LabelValueDefinitionBuilder<'a, S>
where
    S: label_value_definition_state::State,
    S::Blurs: label_value_definition_state::IsUnset,
{
    /// Set the `blurs` field (required)
    pub fn blurs(
        mut self,
        value: impl Into<LabelValueDefinitionBlurs<'a>>,
    ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetBlurs<S>> {
        self._fields.1 = Option::Some(value.into());
        LabelValueDefinitionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, S> {
    /// Set the `defaultSetting` field (optional)
    pub fn default_setting(
        mut self,
        value: impl Into<Option<LabelValueDefinitionDefaultSetting<'a>>>,
    ) -> 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<'a>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

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

impl<'a, S> LabelValueDefinitionBuilder<'a, S>
where
    S: label_value_definition_state::State,
    S::Severity: label_value_definition_state::IsSet,
    S::Blurs: label_value_definition_state::IsSet,
    S::Locales: label_value_definition_state::IsSet,
    S::Identifier: label_value_definition_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LabelValueDefinition<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LabelValueDefinition<'a> {
        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 Lang;
        type Description;
        type Name;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Lang = Unset;
        type Description = Unset;
        type Name = Unset;
    }
    ///State transition - sets the `lang` field to Set
    pub struct SetLang<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLang<S> {}
    impl<S: State> State for SetLang<S> {
        type Lang = Set<members::lang>;
        type Description = S::Description;
        type Name = S::Name;
    }
    ///State transition - sets the `description` field to Set
    pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDescription<S> {}
    impl<S: State> State for SetDescription<S> {
        type Lang = S::Lang;
        type Description = Set<members::description>;
        type Name = S::Name;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetName<S> {}
    impl<S: State> State for SetName<S> {
        type Lang = S::Lang;
        type Description = S::Description;
        type Name = Set<members::name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `lang` field
        pub struct lang(());
        ///Marker type for the `description` field
        pub struct description(());
        ///Marker type for the `name` field
        pub struct name(());
    }
}

/// Builder for constructing an instance of this type
pub struct LabelValueDefinitionStringsBuilder<
    'a,
    S: label_value_definition_strings_state::State,
> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<Language>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

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

impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
where
    S: label_value_definition_strings_state::State,
    S::Lang: label_value_definition_strings_state::IsSet,
    S::Description: label_value_definition_strings_state::IsSet,
    S::Name: label_value_definition_strings_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LabelValueDefinitionStrings<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LabelValueDefinitionStrings<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetValues<S> {}
    impl<S: State> State for SetValues<S> {
        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<'a, S: self_labels_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<label::SelfLabel<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> SelfLabelsBuilder<'a, S>
where
    S: self_labels_state::State,
    S::Values: self_labels_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SelfLabels<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SelfLabels<'a> {
        SelfLabels {
            values: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}