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

//! Generated bindings for the `buzz.bookhive` Lexicon namespace/module.
pub mod book;
pub mod buzz;
pub mod get_book;
pub mod get_book_identifiers;
pub mod get_profile;
pub mod hive_book;
pub mod list_genres;
pub mod search_books;


#[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::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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::buzz_bookhive;
/// User has abandoned the book

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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Activity<S: BosStr = DefaultStr> {
    pub created_at: Datetime,
    ///The hive id of the book
    pub hive_id: S,
    ///The title of the book
    pub title: S,
    pub r#type: ActivityType<S>,
    ///The DID of the user who added the book
    pub user_did: S,
    ///The handle of the user who added the book
    pub user_handle: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ActivityType<S: BosStr = DefaultStr> {
    Review,
    Rated,
    Started,
    Finished,
    Other(S),
}

impl<S: BosStr> ActivityType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Review => "review",
            Self::Rated => "rated",
            Self::Started => "started",
            Self::Finished => "finished",
            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() {
            "review" => Self::Review,
            "rated" => Self::Rated,
            "started" => Self::Started,
            "finished" => Self::Finished,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for ActivityType<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 ActivityType<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 + Default> Default for ActivityType<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for ActivityType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = ActivityType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            ActivityType::Review => ActivityType::Review,
            ActivityType::Rated => ActivityType::Rated,
            ActivityType::Started => ActivityType::Started,
            ActivityType::Finished => ActivityType::Finished,
            ActivityType::Other(v) => ActivityType::Other(v.into_static()),
        }
    }
}

/// External identifiers for a book

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BookIdentifiers<S: BosStr = DefaultStr> {
    ///Goodreads book ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub goodreads_id: Option<S>,
    ///BookHive's internal ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hive_id: Option<S>,
    ///10-digit ISBN
    #[serde(skip_serializing_if = "Option::is_none")]
    pub isbn10: Option<S>,
    ///13-digit ISBN
    #[serde(skip_serializing_if = "Option::is_none")]
    pub isbn13: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Reading progress tracking data

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct BookProgress<S: BosStr = DefaultStr> {
    ///Current chapter the user is on
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_chapter: Option<i64>,
    ///Current page the user is on
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_page: Option<i64>,
    ///How far through the book the reader is (0-100)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub percent: Option<i64>,
    ///Total number of chapters in the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_chapters: Option<i64>,
    ///Total number of pages in the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_pages: Option<i64>,
    ///When the progress was last updated
    pub updated_at: Datetime,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Comment<S: BosStr = DefaultStr> {
    pub book: StrongRef<S>,
    ///The content of the comment.
    pub comment: S,
    ///Client-declared timestamp when this comment was originally created.
    pub created_at: Datetime,
    ///The DID of the user who made the comment
    pub did: S,
    ///The handle of the user who made the comment
    pub handle: S,
    pub parent: StrongRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// User has finished reading the book

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

/// User owns the book

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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Profile<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<S>,
    pub books_read: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    pub display_name: S,
    pub handle: S,
    ///Whether the authed user is following this profile
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_following: Option<bool>,
    pub reviews: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// User is currently reading the book

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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Review<S: BosStr = DefaultStr> {
    ///The date the review was created
    pub created_at: Datetime,
    ///The DID of the user who made the review
    pub did: S,
    ///The handle of the user who made the review
    pub handle: S,
    ///The review content
    pub review: S,
    ///The number of stars given to the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stars: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct UserBook<S: BosStr = DefaultStr> {
    ///The authors of the book (tab separated)
    pub authors: S,
    ///Progress tracking information for the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub book_progress: Option<buzz_bookhive::BookProgress<S>>,
    ///Cover image of the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<S>,
    pub created_at: Datetime,
    ///Book description/summary
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///The date the user finished reading the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub finished_at: Option<Datetime>,
    ///The book's hive id, used to correlate user's books with the hive
    pub hive_id: S,
    ///Average rating (0-1000)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rating: Option<i64>,
    ///The book's review
    #[serde(skip_serializing_if = "Option::is_none")]
    pub review: Option<S>,
    ///Number of stars given to the book (1-10) which will be mapped to 1-5 stars
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stars: Option<i64>,
    ///The date the user started reading the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub started_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<UserBookStatus<S>>,
    ///Cover image of the book
    pub thumbnail: S,
    ///The title of the book
    pub title: S,
    ///The DID of the user who added the book
    pub user_did: S,
    ///The handle of the user who added the book
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user_handle: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UserBookStatus<S: BosStr = DefaultStr> {
    Finished,
    Reading,
    WantToRead,
    Abandoned,
    Owned,
    Other(S),
}

impl<S: BosStr> UserBookStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Finished => "buzz.bookhive.defs#finished",
            Self::Reading => "buzz.bookhive.defs#reading",
            Self::WantToRead => "buzz.bookhive.defs#wantToRead",
            Self::Abandoned => "buzz.bookhive.defs#abandoned",
            Self::Owned => "buzz.bookhive.defs#owned",
            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() {
            "buzz.bookhive.defs#finished" => Self::Finished,
            "buzz.bookhive.defs#reading" => Self::Reading,
            "buzz.bookhive.defs#wantToRead" => Self::WantToRead,
            "buzz.bookhive.defs#abandoned" => Self::Abandoned,
            "buzz.bookhive.defs#owned" => Self::Owned,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for UserBookStatus<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 UserBookStatus<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 + Default> Default for UserBookStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for UserBookStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = UserBookStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            UserBookStatus::Finished => UserBookStatus::Finished,
            UserBookStatus::Reading => UserBookStatus::Reading,
            UserBookStatus::WantToRead => UserBookStatus::WantToRead,
            UserBookStatus::Abandoned => UserBookStatus::Abandoned,
            UserBookStatus::Owned => UserBookStatus::Owned,
            UserBookStatus::Other(v) => UserBookStatus::Other(v.into_static()),
        }
    }
}

/// User wants to read the book

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

impl<S: BosStr> LexiconSchema for Activity<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "activity"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for BookIdentifiers<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "bookIdentifiers"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for BookProgress<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "bookProgress"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.current_chapter {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("current_chapter"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.current_page {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("current_page"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.percent {
            if *value > 100i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("percent"),
                    max: 100i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.percent {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("percent"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.total_chapters {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total_chapters"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.total_pages {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total_pages"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Comment<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "comment"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.comment;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("comment"),
                    max: 100000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.comment;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 10000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("comment"),
                        max: 10000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Profile<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "profile"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.books_read;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("books_read"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.reviews;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("reviews"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Review<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "review"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for UserBook<S> {
    fn nsid() -> &'static str {
        "buzz.bookhive.defs"
    }
    fn def_name() -> &'static str {
        "userBook"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_buzz_bookhive_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.authors;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("authors"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.authors;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("authors"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 5000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 5000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("rating"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.rating {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rating"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.review {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 15000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("review"),
                        max: 15000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.stars {
            if *value > 10i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("stars"),
                    max: 10i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.stars {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("stars"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 1usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("title"),
                    min: 1usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

pub mod activity_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CreatedAt;
        type HiveId;
        type Title;
        type Type;
        type UserDid;
        type UserHandle;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type HiveId = Unset;
        type Title = Unset;
        type Type = Unset;
        type UserDid = Unset;
        type UserHandle = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type HiveId = St::HiveId;
        type Title = St::Title;
        type Type = St::Type;
        type UserDid = St::UserDid;
        type UserHandle = St::UserHandle;
    }
    ///State transition - sets the `hive_id` field to Set
    pub struct SetHiveId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHiveId<St> {}
    impl<St: State> State for SetHiveId<St> {
        type CreatedAt = St::CreatedAt;
        type HiveId = Set<members::hive_id>;
        type Title = St::Title;
        type Type = St::Type;
        type UserDid = St::UserDid;
        type UserHandle = St::UserHandle;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTitle<St> {}
    impl<St: State> State for SetTitle<St> {
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Title = Set<members::title>;
        type Type = St::Type;
        type UserDid = St::UserDid;
        type UserHandle = St::UserHandle;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Title = St::Title;
        type Type = Set<members::r#type>;
        type UserDid = St::UserDid;
        type UserHandle = St::UserHandle;
    }
    ///State transition - sets the `user_did` field to Set
    pub struct SetUserDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserDid<St> {}
    impl<St: State> State for SetUserDid<St> {
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Title = St::Title;
        type Type = St::Type;
        type UserDid = Set<members::user_did>;
        type UserHandle = St::UserHandle;
    }
    ///State transition - sets the `user_handle` field to Set
    pub struct SetUserHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserHandle<St> {}
    impl<St: State> State for SetUserHandle<St> {
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Title = St::Title;
        type Type = St::Type;
        type UserDid = St::UserDid;
        type UserHandle = Set<members::user_handle>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `hive_id` field
        pub struct hive_id(());
        ///Marker type for the `title` field
        pub struct title(());
        ///Marker type for the `type` field
        pub struct r#type(());
        ///Marker type for the `user_did` field
        pub struct user_did(());
        ///Marker type for the `user_handle` field
        pub struct user_handle(());
    }
}

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

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

impl<S: BosStr> Activity<S> {
    /// Create a new builder for this type
    pub fn builder() -> ActivityBuilder<activity_state::Empty, S> {
        ActivityBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::HiveId: activity_state::IsUnset,
{
    /// Set the `hiveId` field (required)
    pub fn hive_id(
        mut self,
        value: impl Into<S>,
    ) -> ActivityBuilder<activity_state::SetHiveId<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ActivityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::Title: activity_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<S>,
    ) -> ActivityBuilder<activity_state::SetTitle<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ActivityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::Type: activity_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<ActivityType<S>>,
    ) -> ActivityBuilder<activity_state::SetType<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ActivityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::UserDid: activity_state::IsUnset,
{
    /// Set the `userDid` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<S>,
    ) -> ActivityBuilder<activity_state::SetUserDid<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ActivityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::UserHandle: activity_state::IsUnset,
{
    /// Set the `userHandle` field (required)
    pub fn user_handle(
        mut self,
        value: impl Into<S>,
    ) -> ActivityBuilder<activity_state::SetUserHandle<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ActivityBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ActivityBuilder<St, S>
where
    St: activity_state::State,
    St::CreatedAt: activity_state::IsSet,
    St::HiveId: activity_state::IsSet,
    St::Title: activity_state::IsSet,
    St::Type: activity_state::IsSet,
    St::UserDid: activity_state::IsSet,
    St::UserHandle: activity_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Activity<S> {
        Activity {
            created_at: self._fields.0.unwrap(),
            hive_id: self._fields.1.unwrap(),
            title: self._fields.2.unwrap(),
            r#type: self._fields.3.unwrap(),
            user_did: self._fields.4.unwrap(),
            user_handle: 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>>) -> Activity<S> {
        Activity {
            created_at: self._fields.0.unwrap(),
            hive_id: self._fields.1.unwrap(),
            title: self._fields.2.unwrap(),
            r#type: self._fields.3.unwrap(),
            user_did: self._fields.4.unwrap(),
            user_handle: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_buzz_bookhive_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("buzz.bookhive.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("abandoned"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("activity"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("type"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("hiveId"), SmolStr::new_static("title"),
                            SmolStr::new_static("userDid"),
                            SmolStr::new_static("userHandle")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hiveId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The hive id of the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The title of the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("userDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the user who added the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("userHandle"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The handle of the user who added the book",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("bookIdentifiers"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("External identifiers for a book"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("goodreadsId"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Goodreads book ID")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hiveId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("BookHive's internal ID"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isbn10"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("10-digit ISBN")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isbn13"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("13-digit ISBN")),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("bookProgress"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Reading progress tracking data"),
                    ),
                    required: Some(vec![SmolStr::new_static("updatedAt")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("currentChapter"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("currentPage"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("percent"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(100i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalChapters"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalPages"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("updatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the progress was last updated"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("comment"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("comment"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("book"), SmolStr::new_static("parent"),
                            SmolStr::new_static("did"), SmolStr::new_static("handle")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("book"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("comment"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The content of the comment."),
                                ),
                                max_length: Some(100000usize),
                                max_graphemes: Some(10000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Client-declared timestamp when this comment was originally created.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the user who made the comment",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The handle of the user who made the comment",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("parent"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("finished"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("owned"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("profile"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("displayName"),
                            SmolStr::new_static("handle"),
                            SmolStr::new_static("booksRead"),
                            SmolStr::new_static("reviews")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avatar"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("booksRead"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("displayName"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("isFollowing"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reviews"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("reading"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("review"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("review"),
                            SmolStr::new_static("createdAt"), SmolStr::new_static("did"),
                            SmolStr::new_static("handle")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The date the review was created"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The DID of the user who made the review",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The handle of the user who made the review",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("review"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The review content")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("stars"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("userBook"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("userDid"), SmolStr::new_static("title"),
                            SmolStr::new_static("authors"),
                            SmolStr::new_static("hiveId"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("thumbnail")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("authors"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The authors of the book (tab separated)",
                                    ),
                                ),
                                min_length: Some(1usize),
                                max_length: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("bookProgress"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "buzz.bookhive.defs#bookProgress",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cover"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Cover image of the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Book description/summary"),
                                ),
                                max_length: Some(5000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("finishedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The date the user finished reading the book",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("hiveId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The book's hive id, used to correlate user's books with the hive",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rating"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(1000i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("review"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The book's review")),
                                max_graphemes: Some(15000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("stars"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                maximum: Some(10i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("startedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The date the user started reading the book",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("thumbnail"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Cover image of the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The title of the book"),
                                ),
                                min_length: Some(1usize),
                                max_length: Some(512usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("userDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the user who added the book"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("userHandle"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The handle of the user who added the book",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("wantToRead"),
                LexUserType::Token(LexToken { ..Default::default() }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> BookProgress<S> {
    /// Create a new builder for this type
    pub fn builder() -> BookProgressBuilder<book_progress_state::Empty, S> {
        BookProgressBuilder::builder()
    }
}

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

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

impl<St: book_progress_state::State, S: BosStr> BookProgressBuilder<St, S> {
    /// Set the `currentChapter` field (optional)
    pub fn current_chapter(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `currentChapter` field to an Option value (optional)
    pub fn maybe_current_chapter(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: book_progress_state::State, S: BosStr> BookProgressBuilder<St, S> {
    /// Set the `currentPage` field (optional)
    pub fn current_page(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `currentPage` field to an Option value (optional)
    pub fn maybe_current_page(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St: book_progress_state::State, S: BosStr> BookProgressBuilder<St, S> {
    /// Set the `totalChapters` field (optional)
    pub fn total_chapters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `totalChapters` field to an Option value (optional)
    pub fn maybe_total_chapters(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: book_progress_state::State, S: BosStr> BookProgressBuilder<St, S> {
    /// Set the `totalPages` field (optional)
    pub fn total_pages(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `totalPages` field to an Option value (optional)
    pub fn maybe_total_pages(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> BookProgressBuilder<St, S>
where
    St: book_progress_state::State,
    St::UpdatedAt: book_progress_state::IsUnset,
{
    /// Set the `updatedAt` field (required)
    pub fn updated_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> BookProgressBuilder<book_progress_state::SetUpdatedAt<St>, S> {
        self._fields.5 = Option::Some(value.into());
        BookProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> BookProgressBuilder<St, S>
where
    St: book_progress_state::State,
    St::UpdatedAt: book_progress_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> BookProgress<S> {
        BookProgress {
            current_chapter: self._fields.0,
            current_page: self._fields.1,
            percent: self._fields.2,
            total_chapters: self._fields.3,
            total_pages: self._fields.4,
            updated_at: 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>>,
    ) -> BookProgress<S> {
        BookProgress {
            current_chapter: self._fields.0,
            current_page: self._fields.1,
            percent: self._fields.2,
            total_chapters: self._fields.3,
            total_pages: self._fields.4,
            updated_at: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod comment_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 Book;
        type Comment;
        type CreatedAt;
        type Did;
        type Handle;
        type Parent;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Book = Unset;
        type Comment = Unset;
        type CreatedAt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type Parent = Unset;
    }
    ///State transition - sets the `book` field to Set
    pub struct SetBook<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBook<St> {}
    impl<St: State> State for SetBook<St> {
        type Book = Set<members::book>;
        type Comment = St::Comment;
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = St::Handle;
        type Parent = St::Parent;
    }
    ///State transition - sets the `comment` field to Set
    pub struct SetComment<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetComment<St> {}
    impl<St: State> State for SetComment<St> {
        type Book = St::Book;
        type Comment = Set<members::comment>;
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = St::Handle;
        type Parent = St::Parent;
    }
    ///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 Book = St::Book;
        type Comment = St::Comment;
        type CreatedAt = Set<members::created_at>;
        type Did = St::Did;
        type Handle = St::Handle;
        type Parent = St::Parent;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type Book = St::Book;
        type Comment = St::Comment;
        type CreatedAt = St::CreatedAt;
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type Parent = St::Parent;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type Book = St::Book;
        type Comment = St::Comment;
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type Parent = St::Parent;
    }
    ///State transition - sets the `parent` field to Set
    pub struct SetParent<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetParent<St> {}
    impl<St: State> State for SetParent<St> {
        type Book = St::Book;
        type Comment = St::Comment;
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = St::Handle;
        type Parent = Set<members::parent>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `book` field
        pub struct book(());
        ///Marker type for the `comment` field
        pub struct comment(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `parent` field
        pub struct parent(());
    }
}

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

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

impl<S: BosStr> Comment<S> {
    /// Create a new builder for this type
    pub fn builder() -> CommentBuilder<comment_state::Empty, S> {
        CommentBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CommentBuilder<St, S>
where
    St: comment_state::State,
    St::Book: comment_state::IsUnset,
{
    /// Set the `book` field (required)
    pub fn book(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> CommentBuilder<comment_state::SetBook<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CommentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> CommentBuilder<St, S>
where
    St: comment_state::State,
    St::Did: comment_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<S>,
    ) -> CommentBuilder<comment_state::SetDid<St>, S> {
        self._fields.3 = Option::Some(value.into());
        CommentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CommentBuilder<St, S>
where
    St: comment_state::State,
    St::Handle: comment_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> CommentBuilder<comment_state::SetHandle<St>, S> {
        self._fields.4 = Option::Some(value.into());
        CommentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CommentBuilder<St, S>
where
    St: comment_state::State,
    St::Parent: comment_state::IsUnset,
{
    /// Set the `parent` field (required)
    pub fn parent(
        mut self,
        value: impl Into<StrongRef<S>>,
    ) -> CommentBuilder<comment_state::SetParent<St>, S> {
        self._fields.5 = Option::Some(value.into());
        CommentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CommentBuilder<St, S>
where
    St: comment_state::State,
    St::Book: comment_state::IsSet,
    St::Comment: comment_state::IsSet,
    St::CreatedAt: comment_state::IsSet,
    St::Did: comment_state::IsSet,
    St::Handle: comment_state::IsSet,
    St::Parent: comment_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Comment<S> {
        Comment {
            book: self._fields.0.unwrap(),
            comment: self._fields.1.unwrap(),
            created_at: self._fields.2.unwrap(),
            did: self._fields.3.unwrap(),
            handle: self._fields.4.unwrap(),
            parent: 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>>) -> Comment<S> {
        Comment {
            book: self._fields.0.unwrap(),
            comment: self._fields.1.unwrap(),
            created_at: self._fields.2.unwrap(),
            did: self._fields.3.unwrap(),
            handle: self._fields.4.unwrap(),
            parent: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod profile_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 BooksRead;
        type DisplayName;
        type Handle;
        type Reviews;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type BooksRead = Unset;
        type DisplayName = Unset;
        type Handle = Unset;
        type Reviews = Unset;
    }
    ///State transition - sets the `books_read` field to Set
    pub struct SetBooksRead<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBooksRead<St> {}
    impl<St: State> State for SetBooksRead<St> {
        type BooksRead = Set<members::books_read>;
        type DisplayName = St::DisplayName;
        type Handle = St::Handle;
        type Reviews = St::Reviews;
    }
    ///State transition - sets the `display_name` field to Set
    pub struct SetDisplayName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDisplayName<St> {}
    impl<St: State> State for SetDisplayName<St> {
        type BooksRead = St::BooksRead;
        type DisplayName = Set<members::display_name>;
        type Handle = St::Handle;
        type Reviews = St::Reviews;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type BooksRead = St::BooksRead;
        type DisplayName = St::DisplayName;
        type Handle = Set<members::handle>;
        type Reviews = St::Reviews;
    }
    ///State transition - sets the `reviews` field to Set
    pub struct SetReviews<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetReviews<St> {}
    impl<St: State> State for SetReviews<St> {
        type BooksRead = St::BooksRead;
        type DisplayName = St::DisplayName;
        type Handle = St::Handle;
        type Reviews = Set<members::reviews>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `books_read` field
        pub struct books_read(());
        ///Marker type for the `display_name` field
        pub struct display_name(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `reviews` field
        pub struct reviews(());
    }
}

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

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

impl<S: BosStr> Profile<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProfileBuilder<profile_state::Empty, S> {
        ProfileBuilder::builder()
    }
}

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

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

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `avatar` field (optional)
    pub fn avatar(mut self, value: impl Into<Option<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<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::BooksRead: profile_state::IsUnset,
{
    /// Set the `booksRead` field (required)
    pub fn books_read(
        mut self,
        value: impl Into<i64>,
    ) -> ProfileBuilder<profile_state::SetBooksRead<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::DisplayName: profile_state::IsUnset,
{
    /// Set the `displayName` field (required)
    pub fn display_name(
        mut self,
        value: impl Into<S>,
    ) -> ProfileBuilder<profile_state::SetDisplayName<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::Handle: profile_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> ProfileBuilder<profile_state::SetHandle<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `isFollowing` field (optional)
    pub fn is_following(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `isFollowing` field to an Option value (optional)
    pub fn maybe_is_following(mut self, value: Option<bool>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::Reviews: profile_state::IsUnset,
{
    /// Set the `reviews` field (required)
    pub fn reviews(
        mut self,
        value: impl Into<i64>,
    ) -> ProfileBuilder<profile_state::SetReviews<St>, S> {
        self._fields.6 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::BooksRead: profile_state::IsSet,
    St::DisplayName: profile_state::IsSet,
    St::Handle: profile_state::IsSet,
    St::Reviews: profile_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Profile<S> {
        Profile {
            avatar: self._fields.0,
            books_read: self._fields.1.unwrap(),
            description: self._fields.2,
            display_name: self._fields.3.unwrap(),
            handle: self._fields.4.unwrap(),
            is_following: self._fields.5,
            reviews: self._fields.6.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>>) -> Profile<S> {
        Profile {
            avatar: self._fields.0,
            books_read: self._fields.1.unwrap(),
            description: self._fields.2,
            display_name: self._fields.3.unwrap(),
            handle: self._fields.4.unwrap(),
            is_following: self._fields.5,
            reviews: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod review_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CreatedAt;
        type Did;
        type Handle;
        type Review;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type Review = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Did = St::Did;
        type Handle = St::Handle;
        type Review = St::Review;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type CreatedAt = St::CreatedAt;
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type Review = St::Review;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type Review = St::Review;
    }
    ///State transition - sets the `review` field to Set
    pub struct SetReview<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetReview<St> {}
    impl<St: State> State for SetReview<St> {
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = St::Handle;
        type Review = Set<members::review>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `review` field
        pub struct review(());
    }
}

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

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

impl<S: BosStr> Review<S> {
    /// Create a new builder for this type
    pub fn builder() -> ReviewBuilder<review_state::Empty, S> {
        ReviewBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> ReviewBuilder<St, S>
where
    St: review_state::State,
    St::Handle: review_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> ReviewBuilder<review_state::SetHandle<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ReviewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ReviewBuilder<St, S>
where
    St: review_state::State,
    St::Review: review_state::IsUnset,
{
    /// Set the `review` field (required)
    pub fn review(
        mut self,
        value: impl Into<S>,
    ) -> ReviewBuilder<review_state::SetReview<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ReviewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> ReviewBuilder<St, S>
where
    St: review_state::State,
    St::CreatedAt: review_state::IsSet,
    St::Did: review_state::IsSet,
    St::Handle: review_state::IsSet,
    St::Review: review_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Review<S> {
        Review {
            created_at: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            review: self._fields.3.unwrap(),
            stars: self._fields.4,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Review<S> {
        Review {
            created_at: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            handle: self._fields.2.unwrap(),
            review: self._fields.3.unwrap(),
            stars: self._fields.4,
            extra_data: Some(extra_data),
        }
    }
}

pub mod user_book_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 Authors;
        type CreatedAt;
        type HiveId;
        type Thumbnail;
        type Title;
        type UserDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Authors = Unset;
        type CreatedAt = Unset;
        type HiveId = Unset;
        type Thumbnail = Unset;
        type Title = Unset;
        type UserDid = Unset;
    }
    ///State transition - sets the `authors` field to Set
    pub struct SetAuthors<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthors<St> {}
    impl<St: State> State for SetAuthors<St> {
        type Authors = Set<members::authors>;
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Thumbnail = St::Thumbnail;
        type Title = St::Title;
        type UserDid = St::UserDid;
    }
    ///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 Authors = St::Authors;
        type CreatedAt = Set<members::created_at>;
        type HiveId = St::HiveId;
        type Thumbnail = St::Thumbnail;
        type Title = St::Title;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `hive_id` field to Set
    pub struct SetHiveId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHiveId<St> {}
    impl<St: State> State for SetHiveId<St> {
        type Authors = St::Authors;
        type CreatedAt = St::CreatedAt;
        type HiveId = Set<members::hive_id>;
        type Thumbnail = St::Thumbnail;
        type Title = St::Title;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `thumbnail` field to Set
    pub struct SetThumbnail<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetThumbnail<St> {}
    impl<St: State> State for SetThumbnail<St> {
        type Authors = St::Authors;
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Thumbnail = Set<members::thumbnail>;
        type Title = St::Title;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTitle<St> {}
    impl<St: State> State for SetTitle<St> {
        type Authors = St::Authors;
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Thumbnail = St::Thumbnail;
        type Title = Set<members::title>;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `user_did` field to Set
    pub struct SetUserDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserDid<St> {}
    impl<St: State> State for SetUserDid<St> {
        type Authors = St::Authors;
        type CreatedAt = St::CreatedAt;
        type HiveId = St::HiveId;
        type Thumbnail = St::Thumbnail;
        type Title = St::Title;
        type UserDid = Set<members::user_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `authors` field
        pub struct authors(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `hive_id` field
        pub struct hive_id(());
        ///Marker type for the `thumbnail` field
        pub struct thumbnail(());
        ///Marker type for the `title` field
        pub struct title(());
        ///Marker type for the `user_did` field
        pub struct user_did(());
    }
}

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

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

impl<S: BosStr> UserBook<S> {
    /// Create a new builder for this type
    pub fn builder() -> UserBookBuilder<user_book_state::Empty, S> {
        UserBookBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::Authors: user_book_state::IsUnset,
{
    /// Set the `authors` field (required)
    pub fn authors(
        mut self,
        value: impl Into<S>,
    ) -> UserBookBuilder<user_book_state::SetAuthors<St>, S> {
        self._fields.0 = Option::Some(value.into());
        UserBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `bookProgress` field (optional)
    pub fn book_progress(
        mut self,
        value: impl Into<Option<buzz_bookhive::BookProgress<S>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `bookProgress` field to an Option value (optional)
    pub fn maybe_book_progress(
        mut self,
        value: Option<buzz_bookhive::BookProgress<S>>,
    ) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `cover` field (optional)
    pub fn cover(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `cover` field to an Option value (optional)
    pub fn maybe_cover(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `finishedAt` field (optional)
    pub fn finished_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `finishedAt` field to an Option value (optional)
    pub fn maybe_finished_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::HiveId: user_book_state::IsUnset,
{
    /// Set the `hiveId` field (required)
    pub fn hive_id(
        mut self,
        value: impl Into<S>,
    ) -> UserBookBuilder<user_book_state::SetHiveId<St>, S> {
        self._fields.6 = Option::Some(value.into());
        UserBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `review` field (optional)
    pub fn review(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `review` field to an Option value (optional)
    pub fn maybe_review(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `stars` field (optional)
    pub fn stars(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `stars` field to an Option value (optional)
    pub fn maybe_stars(mut self, value: Option<i64>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `startedAt` field (optional)
    pub fn started_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `startedAt` field to an Option value (optional)
    pub fn maybe_started_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `status` field (optional)
    pub fn status(mut self, value: impl Into<Option<UserBookStatus<S>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `status` field to an Option value (optional)
    pub fn maybe_status(mut self, value: Option<UserBookStatus<S>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::Thumbnail: user_book_state::IsUnset,
{
    /// Set the `thumbnail` field (required)
    pub fn thumbnail(
        mut self,
        value: impl Into<S>,
    ) -> UserBookBuilder<user_book_state::SetThumbnail<St>, S> {
        self._fields.12 = Option::Some(value.into());
        UserBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::Title: user_book_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<S>,
    ) -> UserBookBuilder<user_book_state::SetTitle<St>, S> {
        self._fields.13 = Option::Some(value.into());
        UserBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::UserDid: user_book_state::IsUnset,
{
    /// Set the `userDid` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<S>,
    ) -> UserBookBuilder<user_book_state::SetUserDid<St>, S> {
        self._fields.14 = Option::Some(value.into());
        UserBookBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: user_book_state::State, S: BosStr> UserBookBuilder<St, S> {
    /// Set the `userHandle` field (optional)
    pub fn user_handle(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `userHandle` field to an Option value (optional)
    pub fn maybe_user_handle(mut self, value: Option<S>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St, S: BosStr> UserBookBuilder<St, S>
where
    St: user_book_state::State,
    St::Authors: user_book_state::IsSet,
    St::CreatedAt: user_book_state::IsSet,
    St::HiveId: user_book_state::IsSet,
    St::Thumbnail: user_book_state::IsSet,
    St::Title: user_book_state::IsSet,
    St::UserDid: user_book_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> UserBook<S> {
        UserBook {
            authors: self._fields.0.unwrap(),
            book_progress: self._fields.1,
            cover: self._fields.2,
            created_at: self._fields.3.unwrap(),
            description: self._fields.4,
            finished_at: self._fields.5,
            hive_id: self._fields.6.unwrap(),
            rating: self._fields.7,
            review: self._fields.8,
            stars: self._fields.9,
            started_at: self._fields.10,
            status: self._fields.11,
            thumbnail: self._fields.12.unwrap(),
            title: self._fields.13.unwrap(),
            user_did: self._fields.14.unwrap(),
            user_handle: self._fields.15,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> UserBook<S> {
        UserBook {
            authors: self._fields.0.unwrap(),
            book_progress: self._fields.1,
            cover: self._fields.2,
            created_at: self._fields.3.unwrap(),
            description: self._fields.4,
            finished_at: self._fields.5,
            hive_id: self._fields.6.unwrap(),
            rating: self._fields.7,
            review: self._fields.8,
            stars: self._fields.9,
            started_at: self._fields.10,
            status: self._fields.11,
            thumbnail: self._fields.12.unwrap(),
            title: self._fields.13.unwrap(),
            user_did: self._fields.14.unwrap(),
            user_handle: self._fields.15,
            extra_data: Some(extra_data),
        }
    }
}