// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.embed.records
//
// 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::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
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::app_bsky::feed::BlockedAuthor;
use crate::app_bsky::feed::GeneratorView;
use crate::app_bsky::graph::ListView;
use crate::app_bsky::graph::StarterPackViewBasic;
use crate::app_bsky::labeler::LabelerView;
use crate::com_atproto::label::Label;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::actor::ProfileDataViewBasic;
use crate::sh_weaver::embed::images;
use crate::sh_weaver::embed::record_with_media;
use crate::sh_weaver::embed::records;
use crate::sh_weaver::embed::video;

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


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


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


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum RecordEmbedViewRecordView<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.embed.records#view")]
    View(Box<records::View<S>>),
    #[serde(rename = "sh.weaver.embed.images#view")]
    ImagesView(Box<images::View<S>>),
    #[serde(rename = "sh.weaver.embed.recordWithMedia#view")]
    RecordWithMediaView(Box<record_with_media::View<S>>),
    #[serde(rename = "sh.weaver.embed.video#view")]
    VideoView(Box<video::View<S>>),
}


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


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ViewUnionRecord<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.embed.records#viewRecord")]
    ViewRecord(Box<records::ViewRecord<S>>),
    #[serde(rename = "sh.weaver.embed.records#viewNotFound")]
    ViewNotFound(Box<records::ViewNotFound<S>>),
    #[serde(rename = "sh.weaver.embed.records#viewBlocked")]
    ViewBlocked(Box<records::ViewBlocked<S>>),
    #[serde(rename = "sh.weaver.embed.records#viewDetached")]
    ViewDetached(Box<records::ViewDetached<S>>),
    #[serde(rename = "app.bsky.feed.defs#generatorView")]
    GeneratorView(Box<GeneratorView<S>>),
    #[serde(rename = "app.bsky.graph.defs#listView")]
    ListView(Box<ListView<S>>),
    #[serde(rename = "app.bsky.labeler.defs#labelerView")]
    LabelerView(Box<LabelerView<S>>),
    #[serde(rename = "app.bsky.graph.defs#starterPackViewBasic")]
    StarterPackViewBasic(Box<StarterPackViewBasic<S>>),
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ViewBlocked<S: BosStr = DefaultStr> {
    pub author: BlockedAuthor<S>,
    pub blocked: bool,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


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


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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ViewRecord<S: BosStr = DefaultStr> {
    pub author: ProfileDataViewBasic<S>,
    pub cid: Cid<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embeds: Option<Vec<records::RecordEmbedView<S>>>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<Vec<Label<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub quote_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reply_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repost_count: Option<i64>,
    pub uri: AtUri<S>,
    ///The record data itself.
    pub value: Data<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Records<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.records;
            #[allow(unused_comparisons)]
            if value.len() > 48usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("records"),
                    max: 48usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for RecordEmbed<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "recordEmbed"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for RecordEmbedView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "recordEmbedView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for View<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "view"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewBlocked<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "viewBlocked"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewDetached<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "viewDetached"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewNotFound<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "viewNotFound"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewRecord<S> {
    fn nsid() -> &'static str {
        "sh.weaver.embed.records"
    }
    fn def_name() -> &'static str {
        "viewRecord"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_embed_records()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Records<S> {
    /// Create a new builder for this type
    pub fn builder() -> RecordsBuilder<records_state::Empty, S> {
        RecordsBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> RecordsBuilder<St, S>
where
    St: records_state::State,
    St::Records: records_state::IsUnset,
{
    /// Set the `records` field (required)
    pub fn records(
        mut self,
        value: impl Into<Vec<records::RecordEmbed<S>>>,
    ) -> RecordsBuilder<records_state::SetRecords<St>, S> {
        self._fields.0 = Option::Some(value.into());
        RecordsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

fn lexicon_doc_sh_weaver_embed_records() -> 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("sh.weaver.embed.records"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("records")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("records"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#recordEmbed"),
                                    ..Default::default()
                                }),
                                max_length: Some(48usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("recordEmbed"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("record")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("recordEmbedView"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("recordView")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("recordView"),
                            LexObjectProperty::Union(LexRefUnion {
                                refs: vec![
                                    CowStr::new_static("sh.weaver.embed.records#view"),
                                    CowStr::new_static("sh.weaver.embed.images#view"),
                                    CowStr::new_static("sh.weaver.embed.recordWithMedia#view"),
                                    CowStr::new_static("sh.weaver.embed.video#view")
                                ],
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("view"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("record")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Union(LexRefUnion {
                                refs: vec![
                                    CowStr::new_static("#viewRecord"),
                                    CowStr::new_static("#viewNotFound"),
                                    CowStr::new_static("#viewBlocked"),
                                    CowStr::new_static("#viewDetached"),
                                    CowStr::new_static("app.bsky.feed.defs#generatorView"),
                                    CowStr::new_static("app.bsky.graph.defs#listView"),
                                    CowStr::new_static("app.bsky.labeler.defs#labelerView"),
                                    CowStr::new_static("app.bsky.graph.defs#starterPackViewBasic")
                                ],
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewBlocked"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("blocked"),
                            SmolStr::new_static("author")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "app.bsky.feed.defs#blockedAuthor",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("blocked"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewDetached"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("detached")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("detached"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewNotFound"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("notFound")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("notFound"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewRecord"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("value"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileDataViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embeds"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#recordEmbedView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.label.defs#label"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("likeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("quoteCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("replyCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("repostCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> RecordEmbed<S> {
    /// Create a new builder for this type
    pub fn builder() -> RecordEmbedBuilder<record_embed_state::Empty, S> {
        RecordEmbedBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> RecordEmbedBuilder<St, S>
where
    St: record_embed_state::State,
    St::Record: record_embed_state::IsUnset,
{
    /// Set the `record` field (required)
    pub fn record(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> RecordEmbedBuilder<record_embed_state::SetRecord<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RecordEmbedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RecordEmbedBuilder<St, S>
where
    St: record_embed_state::State,
    St::Record: record_embed_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> RecordEmbed<S> {
        RecordEmbed {
            name: self._fields.0,
            record: 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>>,
    ) -> RecordEmbed<S> {
        RecordEmbed {
            name: self._fields.0,
            record: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> RecordEmbedView<S> {
    /// Create a new builder for this type
    pub fn builder() -> RecordEmbedViewBuilder<record_embed_view_state::Empty, S> {
        RecordEmbedViewBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> RecordEmbedViewBuilder<St, S>
where
    St: record_embed_view_state::State,
    St::RecordView: record_embed_view_state::IsUnset,
{
    /// Set the `recordView` field (required)
    pub fn record_view(
        mut self,
        value: impl Into<RecordEmbedViewRecordView<S>>,
    ) -> RecordEmbedViewBuilder<record_embed_view_state::SetRecordView<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RecordEmbedViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RecordEmbedViewBuilder<St, S>
where
    St: record_embed_view_state::State,
    St::RecordView: record_embed_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> RecordEmbedView<S> {
        RecordEmbedView {
            name: self._fields.0,
            record_view: 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>>,
    ) -> RecordEmbedView<S> {
        RecordEmbedView {
            name: self._fields.0,
            record_view: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> View<S> {
    /// Create a new builder for this type
    pub fn builder() -> ViewBuilder<view_state::Empty, S> {
        ViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ViewBuilder<St, S>
where
    St: view_state::State,
    St::Record: view_state::IsUnset,
{
    /// Set the `record` field (required)
    pub fn record(
        mut self,
        value: impl Into<ViewUnionRecord<S>>,
    ) -> ViewBuilder<view_state::SetRecord<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ViewBuilder<St, S>
where
    St: view_state::State,
    St::Record: view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> View<S> {
        View {
            record: self._fields.0.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> View<S> {
        View {
            record: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod view_blocked_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 Author;
        type Blocked;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Blocked = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Blocked = St::Blocked;
        type Uri = St::Uri;
    }
    ///State transition - sets the `blocked` field to Set
    pub struct SetBlocked<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBlocked<St> {}
    impl<St: State> State for SetBlocked<St> {
        type Author = St::Author;
        type Blocked = Set<members::blocked>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Blocked = St::Blocked;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `blocked` field
        pub struct blocked(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

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

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

impl<S: BosStr> ViewBlocked<S> {
    /// Create a new builder for this type
    pub fn builder() -> ViewBlockedBuilder<view_blocked_state::Empty, S> {
        ViewBlockedBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ViewBlockedBuilder<St, S>
where
    St: view_blocked_state::State,
    St::Author: view_blocked_state::IsUnset,
{
    /// Set the `author` field (required)
    pub fn author(
        mut self,
        value: impl Into<BlockedAuthor<S>>,
    ) -> ViewBlockedBuilder<view_blocked_state::SetAuthor<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ViewBlockedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ViewBlockedBuilder<St, S>
where
    St: view_blocked_state::State,
    St::Blocked: view_blocked_state::IsUnset,
{
    /// Set the `blocked` field (required)
    pub fn blocked(
        mut self,
        value: impl Into<bool>,
    ) -> ViewBlockedBuilder<view_blocked_state::SetBlocked<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ViewBlockedBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ViewBlockedBuilder<St, S>
where
    St: view_blocked_state::State,
    St::Author: view_blocked_state::IsSet,
    St::Blocked: view_blocked_state::IsSet,
    St::Uri: view_blocked_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ViewBlocked<S> {
        ViewBlocked {
            author: self._fields.0.unwrap(),
            blocked: self._fields.1.unwrap(),
            uri: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ViewBlocked<S> {
        ViewBlocked {
            author: self._fields.0.unwrap(),
            blocked: self._fields.1.unwrap(),
            uri: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ViewDetached<S> {
    /// Create a new builder for this type
    pub fn builder() -> ViewDetachedBuilder<view_detached_state::Empty, S> {
        ViewDetachedBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> ViewDetachedBuilder<St, S>
where
    St: view_detached_state::State,
    St::Detached: view_detached_state::IsSet,
    St::Uri: view_detached_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ViewDetached<S> {
        ViewDetached {
            detached: self._fields.0.unwrap(),
            uri: 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>>,
    ) -> ViewDetached<S> {
        ViewDetached {
            detached: self._fields.0.unwrap(),
            uri: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> ViewNotFound<S> {
    /// Create a new builder for this type
    pub fn builder() -> ViewNotFoundBuilder<view_not_found_state::Empty, S> {
        ViewNotFoundBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ViewNotFoundBuilder<St, S>
where
    St: view_not_found_state::State,
    St::NotFound: view_not_found_state::IsUnset,
{
    /// Set the `notFound` field (required)
    pub fn not_found(
        mut self,
        value: impl Into<bool>,
    ) -> ViewNotFoundBuilder<view_not_found_state::SetNotFound<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ViewNotFoundBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ViewNotFoundBuilder<St, S>
where
    St: view_not_found_state::State,
    St::NotFound: view_not_found_state::IsSet,
    St::Uri: view_not_found_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ViewNotFound<S> {
        ViewNotFound {
            not_found: self._fields.0.unwrap(),
            uri: 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>>,
    ) -> ViewNotFound<S> {
        ViewNotFound {
            not_found: self._fields.0.unwrap(),
            uri: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod view_record_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 Author;
        type Cid;
        type IndexedAt;
        type Uri;
        type Value;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type Uri = Unset;
        type Value = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Uri = St::Uri;
        type Value = St::Value;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type IndexedAt = St::IndexedAt;
        type Uri = St::Uri;
        type Value = St::Value;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type Uri = St::Uri;
        type Value = St::Value;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Uri = Set<members::uri>;
        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 Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Uri = St::Uri;
        type Value = Set<members::value>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `value` field
        pub struct value(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ViewRecordBuilder<St: view_record_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<ProfileDataViewBasic<S>>,
        Option<Cid<S>>,
        Option<Vec<records::RecordEmbedView<S>>>,
        Option<Datetime>,
        Option<Vec<Label<S>>>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<AtUri<S>>,
        Option<Data<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ViewRecord<S> {
    /// Create a new builder for this type
    pub fn builder() -> ViewRecordBuilder<view_record_state::Empty, S> {
        ViewRecordBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ViewRecordBuilder<St, S>
where
    St: view_record_state::State,
    St::Author: view_record_state::IsUnset,
{
    /// Set the `author` field (required)
    pub fn author(
        mut self,
        value: impl Into<ProfileDataViewBasic<S>>,
    ) -> ViewRecordBuilder<view_record_state::SetAuthor<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ViewRecordBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: view_record_state::State, S: BosStr> ViewRecordBuilder<St, S> {
    /// Set the `embeds` field (optional)
    pub fn embeds(
        mut self,
        value: impl Into<Option<Vec<records::RecordEmbedView<S>>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `embeds` field to an Option value (optional)
    pub fn maybe_embeds(
        mut self,
        value: Option<Vec<records::RecordEmbedView<S>>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ViewRecordBuilder<St, S>
where
    St: view_record_state::State,
    St::IndexedAt: view_record_state::IsUnset,
{
    /// Set the `indexedAt` field (required)
    pub fn indexed_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> ViewRecordBuilder<view_record_state::SetIndexedAt<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ViewRecordBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: view_record_state::State, S: BosStr> ViewRecordBuilder<St, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<Vec<Label<S>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: view_record_state::State, S: BosStr> ViewRecordBuilder<St, S> {
    /// Set the `likeCount` field (optional)
    pub fn like_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `likeCount` field to an Option value (optional)
    pub fn maybe_like_count(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: view_record_state::State, S: BosStr> ViewRecordBuilder<St, S> {
    /// Set the `quoteCount` field (optional)
    pub fn quote_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `quoteCount` field to an Option value (optional)
    pub fn maybe_quote_count(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: view_record_state::State, S: BosStr> ViewRecordBuilder<St, S> {
    /// Set the `replyCount` field (optional)
    pub fn reply_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `replyCount` field to an Option value (optional)
    pub fn maybe_reply_count(mut self, value: Option<i64>) -> Self {
        self._fields.7 = value;
        self
    }
}

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

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

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

impl<St, S: BosStr> ViewRecordBuilder<St, S>
where
    St: view_record_state::State,
    St::Author: view_record_state::IsSet,
    St::Cid: view_record_state::IsSet,
    St::IndexedAt: view_record_state::IsSet,
    St::Uri: view_record_state::IsSet,
    St::Value: view_record_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ViewRecord<S> {
        ViewRecord {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            embeds: self._fields.2,
            indexed_at: self._fields.3.unwrap(),
            labels: self._fields.4,
            like_count: self._fields.5,
            quote_count: self._fields.6,
            reply_count: self._fields.7,
            repost_count: self._fields.8,
            uri: self._fields.9.unwrap(),
            value: self._fields.10.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>>,
    ) -> ViewRecord<S> {
        ViewRecord {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            embeds: self._fields.2,
            indexed_at: self._fields.3.unwrap(),
            labels: self._fields.4,
            like_count: self._fields.5,
            quote_count: self._fields.6,
            reply_count: self._fields.7,
            repost_count: self._fields.8,
            uri: self._fields.9.unwrap(),
            value: self._fields.10.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}