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

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

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

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::garden_lexicon::documentation;
/// Documentation for a definition within a lexicon.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DefinitionDoc<S: BosStr = DefaultStr> {
    ///Localized descriptions for this definition.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<Vec<documentation::LocalizedString<S>>>,
    ///The name of the definition being documented (e.g., 'main', 'replyRef').
    pub name: S,
    ///Documentation for properties within this definition.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<Vec<documentation::PropertyDoc<S>>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A string with an associated language code.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LocalizedString<S: BosStr = DefaultStr> {
    ///ISO 639 language code (e.g., 'en', 'es', 'ja').
    pub lang: Language,
    ///The localized string value.
    pub value: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Auxiliary documentation for a lexicon schema, supporting localized descriptions for the lexicon and its properties.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "garden.lexicon.documentation",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Documentation<S: BosStr = DefaultStr> {
    ///Timestamp when this documentation was created.
    pub created_at: Datetime,
    ///Documentation for specific definitions within the lexicon (e.g., main, replyRef).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub definitions: Option<Vec<documentation::DefinitionDoc<S>>>,
    ///Localized descriptions for the lexicon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<Vec<documentation::LocalizedString<S>>>,
    ///The NSID of the lexicon being documented.
    pub lexicon: Nsid<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

/// Documentation for a specific property within a definition.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PropertyDoc<S: BosStr = DefaultStr> {
    ///Localized descriptions for this property.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<Vec<documentation::LocalizedString<S>>>,
    ///The property name being documented.
    pub name: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

impl<S: BosStr> LexiconSchema for DefinitionDoc<S> {
    fn nsid() -> &'static str {
        "garden.lexicon.documentation"
    }
    fn def_name() -> &'static str {
        "definitionDoc"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_documentation()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LocalizedString<S> {
    fn nsid() -> &'static str {
        "garden.lexicon.documentation"
    }
    fn def_name() -> &'static str {
        "localizedString"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_documentation()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.value;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("value"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Collection for Documentation<S> {
    const NSID: &'static str = "garden.lexicon.documentation";
    type Record = DocumentationRecord;
}

impl Collection for DocumentationRecord {
    const NSID: &'static str = "garden.lexicon.documentation";
    type Record = DocumentationRecord;
}

impl<S: BosStr> LexiconSchema for Documentation<S> {
    fn nsid() -> &'static str {
        "garden.lexicon.documentation"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_documentation()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PropertyDoc<S> {
    fn nsid() -> &'static str {
        "garden.lexicon.documentation"
    }
    fn def_name() -> &'static str {
        "propertyDoc"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_documentation()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_garden_lexicon_documentation() -> 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("garden.lexicon.documentation"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("definitionDoc"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Documentation for a definition within a lexicon.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("name")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Localized descriptions for this definition.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#localizedString"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The name of the definition being documented (e.g., 'main', 'replyRef').",
                                    ),
                                ),
                                max_length: Some(512usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("properties"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Documentation for properties within this definition.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#propertyDoc"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("localizedString"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A string with an associated language code."),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("lang"), SmolStr::new_static("value")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("lang"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "ISO 639 language code (e.g., 'en', 'es', 'ja').",
                                    ),
                                ),
                                format: Some(LexStringFormat::Language),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The localized string value."),
                                ),
                                max_length: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Auxiliary documentation for a lexicon schema, supporting localized descriptions for the lexicon and its properties.",
                        ),
                    ),
                    key: Some(CowStr::new_static("nsid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("lexicon"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Timestamp when this documentation was created.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("definitions"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Documentation for specific definitions within the lexicon (e.g., main, replyRef).",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#definitionDoc"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Localized descriptions for the lexicon.",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#localizedString"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lexicon"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The NSID of the lexicon being documented.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Nsid),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("propertyDoc"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Documentation for a specific property within a definition.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("name")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Localized descriptions for this property.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#localizedString"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The property name being documented."),
                                ),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod localized_string_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 Value;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Lang = Unset;
        type Value = Unset;
    }
    ///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 Lang = Set<members::lang>;
        type Value = St::Value;
    }
    ///State transition - sets the `value` field to Set
    pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetValue<St> {}
    impl<St: State> State for SetValue<St> {
        type Lang = St::Lang;
        type Value = Set<members::value>;
    }
    /// 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 `value` field
        pub struct value(());
    }
}

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

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

impl<S: BosStr> LocalizedString<S> {
    /// Create a new builder for this type
    pub fn builder() -> LocalizedStringBuilder<localized_string_state::Empty, S> {
        LocalizedStringBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LocalizedStringBuilder<St, S>
where
    St: localized_string_state::State,
    St::Value: localized_string_state::IsUnset,
{
    /// Set the `value` field (required)
    pub fn value(
        mut self,
        value: impl Into<S>,
    ) -> LocalizedStringBuilder<localized_string_state::SetValue<St>, S> {
        self._fields.1 = Option::Some(value.into());
        LocalizedStringBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LocalizedStringBuilder<St, S>
where
    St: localized_string_state::State,
    St::Lang: localized_string_state::IsSet,
    St::Value: localized_string_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LocalizedString<S> {
        LocalizedString {
            lang: self._fields.0.unwrap(),
            value: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> LocalizedString<S> {
        LocalizedString {
            lang: self._fields.0.unwrap(),
            value: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

/// Builder for constructing an instance of this type.
pub struct DocumentationBuilder<St: documentation_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<Vec<documentation::DefinitionDoc<S>>>,
        Option<Vec<documentation::LocalizedString<S>>>,
        Option<Nsid<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Documentation<S> {
    /// Create a new builder for this type
    pub fn builder() -> DocumentationBuilder<documentation_state::Empty, S> {
        DocumentationBuilder::builder()
    }
}

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

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

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

impl<St: documentation_state::State, S: BosStr> DocumentationBuilder<St, S> {
    /// Set the `definitions` field (optional)
    pub fn definitions(
        mut self,
        value: impl Into<Option<Vec<documentation::DefinitionDoc<S>>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `definitions` field to an Option value (optional)
    pub fn maybe_definitions(
        mut self,
        value: Option<Vec<documentation::DefinitionDoc<S>>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: documentation_state::State, S: BosStr> DocumentationBuilder<St, S> {
    /// Set the `description` field (optional)
    pub fn description(
        mut self,
        value: impl Into<Option<Vec<documentation::LocalizedString<S>>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `description` field to an Option value (optional)
    pub fn maybe_description(
        mut self,
        value: Option<Vec<documentation::LocalizedString<S>>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> DocumentationBuilder<St, S>
where
    St: documentation_state::State,
    St::Lexicon: documentation_state::IsUnset,
{
    /// Set the `lexicon` field (required)
    pub fn lexicon(
        mut self,
        value: impl Into<Nsid<S>>,
    ) -> DocumentationBuilder<documentation_state::SetLexicon<St>, S> {
        self._fields.3 = Option::Some(value.into());
        DocumentationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> DocumentationBuilder<St, S>
where
    St: documentation_state::State,
    St::CreatedAt: documentation_state::IsSet,
    St::Lexicon: documentation_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Documentation<S> {
        Documentation {
            created_at: self._fields.0.unwrap(),
            definitions: self._fields.1,
            description: self._fields.2,
            lexicon: self._fields.3.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>>,
    ) -> Documentation<S> {
        Documentation {
            created_at: self._fields.0.unwrap(),
            definitions: self._fields.1,
            description: self._fields.2,
            lexicon: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}