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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon, 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;

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RecordEmbed<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub name: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub record: StrongRef<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RecordEmbedView<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub name: Option<CowStr<'a>>,
    #[serde(borrow)]
    pub record_view: RecordEmbedViewRecordView<'a>,
}


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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct View<'a> {
    #[serde(borrow)]
    pub record: ViewUnionRecord<'a>,
}


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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ViewBlocked<'a> {
    #[serde(borrow)]
    pub author: BlockedAuthor<'a>,
    pub blocked: bool,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ViewDetached<'a> {
    pub detached: bool,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ViewNotFound<'a> {
    pub not_found: bool,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ViewRecord<'a> {
    #[serde(borrow)]
    pub author: ProfileDataViewBasic<'a>,
    #[serde(borrow)]
    pub cid: Cid<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub embeds: Option<Vec<records::RecordEmbedView<'a>>>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub labels: Option<Vec<Label<'a>>>,
    #[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>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    ///The record data itself.
    #[serde(borrow)]
    pub value: Data<'a>,
}

impl<'a> LexiconSchema for Records<'a> {
    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<'a> LexiconSchema for RecordEmbed<'a> {
    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<'a> LexiconSchema for RecordEmbedView<'a> {
    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<'a> LexiconSchema for View<'a> {
    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<'a> LexiconSchema for ViewBlocked<'a> {
    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<'a> LexiconSchema for ViewDetached<'a> {
    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<'a> LexiconSchema for ViewNotFound<'a> {
    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<'a> LexiconSchema for ViewRecord<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRecords<S> {}
    impl<S: State> State for SetRecords<S> {
        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<'a, S: records_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<records::RecordEmbed<'a>>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> RecordsBuilder<'a, S>
where
    S: records_state::State,
    S::Records: records_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Records<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> Records<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRecord<S> {}
    impl<S: State> State for SetRecord<S> {
        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<'a, S: record_embed_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<StrongRef<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> RecordEmbedBuilder<'a, S>
where
    S: record_embed_state::State,
    S::Record: record_embed_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RecordEmbed<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> RecordEmbed<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRecordView<S> {}
    impl<S: State> State for SetRecordView<S> {
        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<'a, S: record_embed_view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<RecordEmbedViewRecordView<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> RecordEmbedViewBuilder<'a, S>
where
    S: record_embed_view_state::State,
    S::RecordView: record_embed_view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RecordEmbedView<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> RecordEmbedView<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRecord<S> {}
    impl<S: State> State for SetRecord<S> {
        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<'a, S: view_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<ViewUnionRecord<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> ViewBuilder<'a, S>
where
    S: view_state::State,
    S::Record: view_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> View<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> View<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAuthor<S> {}
    impl<S: State> State for SetAuthor<S> {
        type Author = Set<members::author>;
        type Blocked = S::Blocked;
        type Uri = S::Uri;
    }
    ///State transition - sets the `blocked` field to Set
    pub struct SetBlocked<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBlocked<S> {}
    impl<S: State> State for SetBlocked<S> {
        type Author = S::Author;
        type Blocked = Set<members::blocked>;
        type Uri = S::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Author = S::Author;
        type Blocked = S::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<'a, S: view_blocked_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlockedAuthor<'a>>, Option<bool>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

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

impl<'a, S> ViewBlockedBuilder<'a, S>
where
    S: view_blocked_state::State,
    S::Author: view_blocked_state::IsSet,
    S::Blocked: view_blocked_state::IsSet,
    S::Uri: view_blocked_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ViewBlocked<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> ViewBlocked<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDetached<S> {}
    impl<S: State> State for SetDetached<S> {
        type Detached = Set<members::detached>;
        type Uri = S::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Detached = S::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<'a, S: view_detached_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<bool>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> ViewDetachedBuilder<'a, S>
where
    S: view_detached_state::State,
    S::Detached: view_detached_state::IsSet,
    S::Uri: view_detached_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ViewDetached<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> ViewDetached<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetNotFound<S> {}
    impl<S: State> State for SetNotFound<S> {
        type NotFound = Set<members::not_found>;
        type Uri = S::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type NotFound = S::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<'a, S: view_not_found_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<bool>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> ViewNotFoundBuilder<'a, S>
where
    S: view_not_found_state::State,
    S::NotFound: view_not_found_state::IsSet,
    S::Uri: view_not_found_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ViewNotFound<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> ViewNotFound<'a> {
        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 Uri;
        type Cid;
        type Author;
        type IndexedAt;
        type Value;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
        type Cid = Unset;
        type Author = Unset;
        type IndexedAt = Unset;
        type Value = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Uri = Set<members::uri>;
        type Cid = S::Cid;
        type Author = S::Author;
        type IndexedAt = S::IndexedAt;
        type Value = S::Value;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type Uri = S::Uri;
        type Cid = Set<members::cid>;
        type Author = S::Author;
        type IndexedAt = S::IndexedAt;
        type Value = S::Value;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAuthor<S> {}
    impl<S: State> State for SetAuthor<S> {
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Author = Set<members::author>;
        type IndexedAt = S::IndexedAt;
        type Value = S::Value;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
    impl<S: State> State for SetIndexedAt<S> {
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Author = S::Author;
        type IndexedAt = Set<members::indexed_at>;
        type Value = S::Value;
    }
    ///State transition - sets the `value` field to Set
    pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetValue<S> {}
    impl<S: State> State for SetValue<S> {
        type Uri = S::Uri;
        type Cid = S::Cid;
        type Author = S::Author;
        type IndexedAt = S::IndexedAt;
        type Value = Set<members::value>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `value` field
        pub struct value(());
    }
}

/// Builder for constructing an instance of this type
pub struct ViewRecordBuilder<'a, S: view_record_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<ProfileDataViewBasic<'a>>,
        Option<Cid<'a>>,
        Option<Vec<records::RecordEmbedView<'a>>>,
        Option<Datetime>,
        Option<Vec<Label<'a>>>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<AtUri<'a>>,
        Option<Data<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S: view_record_state::State> ViewRecordBuilder<'a, S> {
    /// Set the `embeds` field (optional)
    pub fn embeds(
        mut self,
        value: impl Into<Option<Vec<records::RecordEmbedView<'a>>>>,
    ) -> 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<'a>>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<'a, S: view_record_state::State> ViewRecordBuilder<'a, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> 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<'a>>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: view_record_state::State> ViewRecordBuilder<'a, 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<'a, S: view_record_state::State> ViewRecordBuilder<'a, 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<'a, S: view_record_state::State> ViewRecordBuilder<'a, 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<'a, S: view_record_state::State> ViewRecordBuilder<'a, 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<'a, S> ViewRecordBuilder<'a, S>
where
    S: view_record_state::State,
    S::Uri: view_record_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> ViewRecordBuilder<'a, view_record_state::SetUri<S>> {
        self._fields.9 = Option::Some(value.into());
        ViewRecordBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> ViewRecordBuilder<'a, S>
where
    S: view_record_state::State,
    S::Uri: view_record_state::IsSet,
    S::Cid: view_record_state::IsSet,
    S::Author: view_record_state::IsSet,
    S::IndexedAt: view_record_state::IsSet,
    S::Value: view_record_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ViewRecord<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> ViewRecord<'a> {
        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),
        }
    }
}