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

//! Generated bindings for the `sh.weaver.graph` Lexicon namespace/module.
pub mod bookmark;
pub mod follow;
pub mod follow_accept;
pub mod follow_gate;
pub mod get_actor_bookmarks;
pub mod get_actor_likes;
pub mod get_actor_lists;
pub mod get_actor_subscriptions;
pub mod get_bookmarked_by;
pub mod get_followers;
pub mod get_following;
pub mod get_liked_by;
pub mod get_list;
pub mod get_popular_tags;
pub mod get_resource_tags;
pub mod get_subscribers;
pub mod get_tag_suggestions;
pub mod get_tagged_resources;
pub mod get_trending_tags;
pub mod like;
pub mod list;
pub mod listitem;
pub mod subscribe;
pub mod subscribe_accept;
pub mod tag;


#[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, UriValue};
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::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::EntryView;
use crate::sh_weaver::notebook::NotebookView;
use crate::sh_weaver::graph;
/// A community tag with how many people applied it.

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

/// A curated collection of notebooks/entries for sharing.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Curatelist;
impl core::fmt::Display for Curatelist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "curatelist")
    }
}

/// An item in a list with hydrated subject.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListItemView<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub added_at: Option<Datetime>,
    pub subject: ListItemViewSubject<S>,
    pub uri: AtUri<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 ListItemViewSubject<S: BosStr = DefaultStr> {
    #[serde(rename = "sh.weaver.notebook.defs#notebookView")]
    NotebookView(Box<NotebookView<S>>),
    #[serde(rename = "sh.weaver.notebook.defs#entryView")]
    EntryView(Box<EntryView<S>>),
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ListPurpose<S: BosStr = DefaultStr> {
    ShWeaverGraphDefsCuratelist,
    ShWeaverGraphDefsReadinglist,
    ShWeaverGraphDefsSerieslist,
    Other(S),
}

impl<S: BosStr> ListPurpose<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::ShWeaverGraphDefsCuratelist => "sh.weaver.graph.defs#curatelist",
            Self::ShWeaverGraphDefsReadinglist => "sh.weaver.graph.defs#readinglist",
            Self::ShWeaverGraphDefsSerieslist => "sh.weaver.graph.defs#serieslist",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "sh.weaver.graph.defs#curatelist" => Self::ShWeaverGraphDefsCuratelist,
            "sh.weaver.graph.defs#readinglist" => Self::ShWeaverGraphDefsReadinglist,
            "sh.weaver.graph.defs#serieslist" => Self::ShWeaverGraphDefsSerieslist,
            _ => Self::Other(s),
        }
    }
}

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

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for ListPurpose<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ListPurpose<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ListPurpose::ShWeaverGraphDefsCuratelist => {
                ListPurpose::ShWeaverGraphDefsCuratelist
            }
            ListPurpose::ShWeaverGraphDefsReadinglist => {
                ListPurpose::ShWeaverGraphDefsReadinglist
            }
            ListPurpose::ShWeaverGraphDefsSerieslist => {
                ListPurpose::ShWeaverGraphDefsSerieslist
            }
            ListPurpose::Other(v) => ListPurpose::Other(v.into_static()),
        }
    }
}

/// Hydrated view of a list.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListView<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<UriValue<S>>,
    pub cid: Cid<S>,
    pub creator: ProfileViewBasic<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub indexed_at: Datetime,
    pub item_count: i64,
    pub name: S,
    pub purpose: graph::ListPurpose<S>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer_subscribed: Option<AtUri<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A personal reading list.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Readinglist;
impl core::fmt::Display for Readinglist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "readinglist")
    }
}

/// All tags for a resource, grouped by source.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ResourceTagsView<S: BosStr = DefaultStr> {
    ///Tags from the record itself (author-applied).
    pub author_tags: Vec<S>,
    ///Aggregated community-applied tags with counts.
    pub community_tags: Vec<graph::CommunityTagCount<S>>,
    pub resource: StrongRef<S>,
    ///Tags the current viewer has applied.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer_applied_tags: Option<Vec<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// An ordered series of related works (sequels, spin-offs).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct Serieslist;
impl core::fmt::Display for Serieslist {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "serieslist")
    }
}

/// A single tag application with who applied it.

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

/// Aggregated view of a tag with usage statistics.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TagView<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub entry_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub notebook_count: Option<i64>,
    ///Uses in the last 30 days.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recent_use_count: Option<i64>,
    pub tag: S,
    ///Appview-computed trending score.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trending_score: Option<i64>,
    ///Total number of resources tagged with this tag.
    pub use_count: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for CommunityTagCount<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "communityTagCount"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ListItemView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "listItemView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ListView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "listView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ResourceTagsView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "resourceTagsView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for TagApplicationView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "tagApplicationView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for TagView<S> {
    fn nsid() -> &'static str {
        "sh.weaver.graph.defs"
    }
    fn def_name() -> &'static str {
        "tagView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_graph_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> CommunityTagCount<S> {
    /// Create a new builder for this type
    pub fn builder() -> CommunityTagCountBuilder<community_tag_count_state::Empty, S> {
        CommunityTagCountBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CommunityTagCountBuilder<St, S>
where
    St: community_tag_count_state::State,
    St::Count: community_tag_count_state::IsUnset,
{
    /// Set the `count` field (required)
    pub fn count(
        mut self,
        value: impl Into<i64>,
    ) -> CommunityTagCountBuilder<community_tag_count_state::SetCount<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CommunityTagCountBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> CommunityTagCountBuilder<St, S>
where
    St: community_tag_count_state::State,
    St::Count: community_tag_count_state::IsSet,
    St::Tag: community_tag_count_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CommunityTagCount<S> {
        CommunityTagCount {
            count: self._fields.0.unwrap(),
            tag: 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>>,
    ) -> CommunityTagCount<S> {
        CommunityTagCount {
            count: self._fields.0.unwrap(),
            tag: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_graph_defs() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("sh.weaver.graph.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("communityTagCount"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A community tag with how many people applied it.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("tag"), SmolStr::new_static("count")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("curatelist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("listItemView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("An item in a list with hydrated subject."),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("subject")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("addedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("subject"),
                            LexObjectProperty::Union(LexRefUnion {
                                refs: vec![
                                    CowStr::new_static("sh.weaver.notebook.defs#notebookView"),
                                    CowStr::new_static("sh.weaver.notebook.defs#entryView")
                                ],
                                ..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("listPurpose"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("listView"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Hydrated view of a list.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("creator"), SmolStr::new_static("name"),
                            SmolStr::new_static("purpose"),
                            SmolStr::new_static("itemCount"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avatar"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creator"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("itemCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("purpose"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#listPurpose"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewerSubscribed"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("readinglist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("resourceTagsView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("All tags for a resource, grouped by source."),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("resource"),
                            SmolStr::new_static("authorTags"),
                            SmolStr::new_static("communityTags")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("authorTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Tags from the record itself (author-applied).",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("communityTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Aggregated community-applied tags with counts.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#communityTagCount"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resource"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewerAppliedTags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Tags the current viewer has applied."),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("serieslist"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("tagApplicationView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single tag application with who applied it.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("tag"),
                            SmolStr::new_static("appliedBy"),
                            SmolStr::new_static("createdAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("appliedBy"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..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("tagView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Aggregated view of a tag with usage statistics.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("tag"), SmolStr::new_static("useCount")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("entryCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("notebookCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("recentUseCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("trendingScore"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("useCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> ListItemView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ListItemViewBuilder<list_item_view_state::Empty, S> {
        ListItemViewBuilder::builder()
    }
}

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

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

impl<St: list_item_view_state::State, S: BosStr> ListItemViewBuilder<St, S> {
    /// Set the `addedAt` field (optional)
    pub fn added_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `addedAt` field to an Option value (optional)
    pub fn maybe_added_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> ListItemViewBuilder<St, S>
where
    St: list_item_view_state::State,
    St::Subject: list_item_view_state::IsUnset,
{
    /// Set the `subject` field (required)
    pub fn subject(
        mut self,
        value: impl Into<ListItemViewSubject<S>>,
    ) -> ListItemViewBuilder<list_item_view_state::SetSubject<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ListItemViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ListItemViewBuilder<St, S>
where
    St: list_item_view_state::State,
    St::Subject: list_item_view_state::IsSet,
    St::Uri: list_item_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ListItemView<S> {
        ListItemView {
            added_at: self._fields.0,
            subject: 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>>,
    ) -> ListItemView<S> {
        ListItemView {
            added_at: self._fields.0,
            subject: self._fields.1.unwrap(),
            uri: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod list_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 Cid;
        type Creator;
        type IndexedAt;
        type ItemCount;
        type Name;
        type Purpose;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Cid = Unset;
        type Creator = Unset;
        type IndexedAt = Unset;
        type ItemCount = Unset;
        type Name = Unset;
        type Purpose = Unset;
        type Uri = Unset;
    }
    ///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 Cid = Set<members::cid>;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Uri = St::Uri;
    }
    ///State transition - sets the `creator` field to Set
    pub struct SetCreator<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreator<St> {}
    impl<St: State> State for SetCreator<St> {
        type Cid = St::Cid;
        type Creator = Set<members::creator>;
        type IndexedAt = St::IndexedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Uri = St::Uri;
    }
    ///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 Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = Set<members::indexed_at>;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Uri = St::Uri;
    }
    ///State transition - sets the `item_count` field to Set
    pub struct SetItemCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetItemCount<St> {}
    impl<St: State> State for SetItemCount<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type ItemCount = Set<members::item_count>;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Uri = St::Uri;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type ItemCount = St::ItemCount;
        type Name = Set<members::name>;
        type Purpose = St::Purpose;
        type Uri = St::Uri;
    }
    ///State transition - sets the `purpose` field to Set
    pub struct SetPurpose<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPurpose<St> {}
    impl<St: State> State for SetPurpose<St> {
        type Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Purpose = Set<members::purpose>;
        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 Cid = St::Cid;
        type Creator = St::Creator;
        type IndexedAt = St::IndexedAt;
        type ItemCount = St::ItemCount;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `creator` field
        pub struct creator(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `item_count` field
        pub struct item_count(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `purpose` field
        pub struct purpose(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ListViewBuilder<St: list_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<UriValue<S>>,
        Option<Cid<S>>,
        Option<ProfileViewBasic<S>>,
        Option<S>,
        Option<Datetime>,
        Option<i64>,
        Option<S>,
        Option<graph::ListPurpose<S>>,
        Option<AtUri<S>>,
        Option<AtUri<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ListView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ListViewBuilder<list_view_state::Empty, S> {
        ListViewBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> ListViewBuilder<St, S>
where
    St: list_view_state::State,
    St::Creator: list_view_state::IsUnset,
{
    /// Set the `creator` field (required)
    pub fn creator(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> ListViewBuilder<list_view_state::SetCreator<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> ListViewBuilder<St, S>
where
    St: list_view_state::State,
    St::ItemCount: list_view_state::IsUnset,
{
    /// Set the `itemCount` field (required)
    pub fn item_count(
        mut self,
        value: impl Into<i64>,
    ) -> ListViewBuilder<list_view_state::SetItemCount<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ListViewBuilder<St, S>
where
    St: list_view_state::State,
    St::Purpose: list_view_state::IsUnset,
{
    /// Set the `purpose` field (required)
    pub fn purpose(
        mut self,
        value: impl Into<graph::ListPurpose<S>>,
    ) -> ListViewBuilder<list_view_state::SetPurpose<St>, S> {
        self._fields.7 = Option::Some(value.into());
        ListViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: list_view_state::State, S: BosStr> ListViewBuilder<St, S> {
    /// Set the `viewerSubscribed` field (optional)
    pub fn viewer_subscribed(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `viewerSubscribed` field to an Option value (optional)
    pub fn maybe_viewer_subscribed(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> ListViewBuilder<St, S>
where
    St: list_view_state::State,
    St::Cid: list_view_state::IsSet,
    St::Creator: list_view_state::IsSet,
    St::IndexedAt: list_view_state::IsSet,
    St::ItemCount: list_view_state::IsSet,
    St::Name: list_view_state::IsSet,
    St::Purpose: list_view_state::IsSet,
    St::Uri: list_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ListView<S> {
        ListView {
            avatar: self._fields.0,
            cid: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            description: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            item_count: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            purpose: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer_subscribed: self._fields.9,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ListView<S> {
        ListView {
            avatar: self._fields.0,
            cid: self._fields.1.unwrap(),
            creator: self._fields.2.unwrap(),
            description: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            item_count: self._fields.5.unwrap(),
            name: self._fields.6.unwrap(),
            purpose: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer_subscribed: self._fields.9,
            extra_data: Some(extra_data),
        }
    }
}

pub mod resource_tags_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 AuthorTags;
        type CommunityTags;
        type Resource;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AuthorTags = Unset;
        type CommunityTags = Unset;
        type Resource = Unset;
    }
    ///State transition - sets the `author_tags` field to Set
    pub struct SetAuthorTags<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthorTags<St> {}
    impl<St: State> State for SetAuthorTags<St> {
        type AuthorTags = Set<members::author_tags>;
        type CommunityTags = St::CommunityTags;
        type Resource = St::Resource;
    }
    ///State transition - sets the `community_tags` field to Set
    pub struct SetCommunityTags<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCommunityTags<St> {}
    impl<St: State> State for SetCommunityTags<St> {
        type AuthorTags = St::AuthorTags;
        type CommunityTags = Set<members::community_tags>;
        type Resource = St::Resource;
    }
    ///State transition - sets the `resource` field to Set
    pub struct SetResource<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetResource<St> {}
    impl<St: State> State for SetResource<St> {
        type AuthorTags = St::AuthorTags;
        type CommunityTags = St::CommunityTags;
        type Resource = Set<members::resource>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author_tags` field
        pub struct author_tags(());
        ///Marker type for the `community_tags` field
        pub struct community_tags(());
        ///Marker type for the `resource` field
        pub struct resource(());
    }
}

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

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

impl<S: BosStr> ResourceTagsView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ResourceTagsViewBuilder<resource_tags_view_state::Empty, S> {
        ResourceTagsViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ResourceTagsViewBuilder<St, S>
where
    St: resource_tags_view_state::State,
    St::AuthorTags: resource_tags_view_state::IsUnset,
{
    /// Set the `authorTags` field (required)
    pub fn author_tags(
        mut self,
        value: impl Into<Vec<S>>,
    ) -> ResourceTagsViewBuilder<resource_tags_view_state::SetAuthorTags<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ResourceTagsViewBuilder<St, S>
where
    St: resource_tags_view_state::State,
    St::CommunityTags: resource_tags_view_state::IsUnset,
{
    /// Set the `communityTags` field (required)
    pub fn community_tags(
        mut self,
        value: impl Into<Vec<graph::CommunityTagCount<S>>>,
    ) -> ResourceTagsViewBuilder<resource_tags_view_state::SetCommunityTags<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ResourceTagsViewBuilder<St, S>
where
    St: resource_tags_view_state::State,
    St::Resource: resource_tags_view_state::IsUnset,
{
    /// Set the `resource` field (required)
    pub fn resource(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> ResourceTagsViewBuilder<resource_tags_view_state::SetResource<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ResourceTagsViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: resource_tags_view_state::State, S: BosStr> ResourceTagsViewBuilder<St, S> {
    /// Set the `viewerAppliedTags` field (optional)
    pub fn viewer_applied_tags(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `viewerAppliedTags` field to an Option value (optional)
    pub fn maybe_viewer_applied_tags(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> ResourceTagsViewBuilder<St, S>
where
    St: resource_tags_view_state::State,
    St::AuthorTags: resource_tags_view_state::IsSet,
    St::CommunityTags: resource_tags_view_state::IsSet,
    St::Resource: resource_tags_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ResourceTagsView<S> {
        ResourceTagsView {
            author_tags: self._fields.0.unwrap(),
            community_tags: self._fields.1.unwrap(),
            resource: self._fields.2.unwrap(),
            viewer_applied_tags: self._fields.3,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ResourceTagsView<S> {
        ResourceTagsView {
            author_tags: self._fields.0.unwrap(),
            community_tags: self._fields.1.unwrap(),
            resource: self._fields.2.unwrap(),
            viewer_applied_tags: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> TagApplicationView<S> {
    /// Create a new builder for this type
    pub fn builder() -> TagApplicationViewBuilder<tag_application_view_state::Empty, S> {
        TagApplicationViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> TagApplicationViewBuilder<St, S>
where
    St: tag_application_view_state::State,
    St::AppliedBy: tag_application_view_state::IsUnset,
{
    /// Set the `appliedBy` field (required)
    pub fn applied_by(
        mut self,
        value: impl Into<ProfileViewBasic<S>>,
    ) -> TagApplicationViewBuilder<tag_application_view_state::SetAppliedBy<St>, S> {
        self._fields.0 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> TagApplicationViewBuilder<St, S>
where
    St: tag_application_view_state::State,
    St::Tag: tag_application_view_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<S>,
    ) -> TagApplicationViewBuilder<tag_application_view_state::SetTag<St>, S> {
        self._fields.2 = Option::Some(value.into());
        TagApplicationViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> TagApplicationViewBuilder<St, S>
where
    St: tag_application_view_state::State,
    St::AppliedBy: tag_application_view_state::IsSet,
    St::CreatedAt: tag_application_view_state::IsSet,
    St::Tag: tag_application_view_state::IsSet,
    St::Uri: tag_application_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TagApplicationView<S> {
        TagApplicationView {
            applied_by: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            tag: self._fields.2.unwrap(),
            uri: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> TagApplicationView<S> {
        TagApplicationView {
            applied_by: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            tag: self._fields.2.unwrap(),
            uri: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> TagView<S> {
    /// Create a new builder for this type
    pub fn builder() -> TagViewBuilder<tag_view_state::Empty, S> {
        TagViewBuilder::builder()
    }
}

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

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

impl<St: tag_view_state::State, S: BosStr> TagViewBuilder<St, S> {
    /// Set the `entryCount` field (optional)
    pub fn entry_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `entryCount` field to an Option value (optional)
    pub fn maybe_entry_count(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: tag_view_state::State, S: BosStr> TagViewBuilder<St, S> {
    /// Set the `notebookCount` field (optional)
    pub fn notebook_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `notebookCount` field to an Option value (optional)
    pub fn maybe_notebook_count(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: tag_view_state::State, S: BosStr> TagViewBuilder<St, S> {
    /// Set the `recentUseCount` field (optional)
    pub fn recent_use_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `recentUseCount` field to an Option value (optional)
    pub fn maybe_recent_use_count(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> TagViewBuilder<St, S>
where
    St: tag_view_state::State,
    St::Tag: tag_view_state::IsUnset,
{
    /// Set the `tag` field (required)
    pub fn tag(
        mut self,
        value: impl Into<S>,
    ) -> TagViewBuilder<tag_view_state::SetTag<St>, S> {
        self._fields.3 = Option::Some(value.into());
        TagViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: tag_view_state::State, S: BosStr> TagViewBuilder<St, S> {
    /// Set the `trendingScore` field (optional)
    pub fn trending_score(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `trendingScore` field to an Option value (optional)
    pub fn maybe_trending_score(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> TagViewBuilder<St, S>
where
    St: tag_view_state::State,
    St::UseCount: tag_view_state::IsUnset,
{
    /// Set the `useCount` field (required)
    pub fn use_count(
        mut self,
        value: impl Into<i64>,
    ) -> TagViewBuilder<tag_view_state::SetUseCount<St>, S> {
        self._fields.5 = Option::Some(value.into());
        TagViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TagViewBuilder<St, S>
where
    St: tag_view_state::State,
    St::Tag: tag_view_state::IsSet,
    St::UseCount: tag_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TagView<S> {
        TagView {
            entry_count: self._fields.0,
            notebook_count: self._fields.1,
            recent_use_count: self._fields.2,
            tag: self._fields.3.unwrap(),
            trending_score: self._fields.4,
            use_count: self._fields.5.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> TagView<S> {
        TagView {
            entry_count: self._fields.0,
            notebook_count: self._fields.1,
            recent_use_count: self._fields.2,
            tag: self._fields.3.unwrap(),
            trending_score: self._fields.4,
            use_count: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}