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

//! Generated bindings for the `space.polymodel.library` Lexicon namespace/module.
pub mod get_author_things;
pub mod get_feed;
pub mod get_thing;
pub mod model;
pub mod part;
pub mod search_things;
pub mod thing;


#[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::blob::BlobRef;
use jacquard_common::types::string::{Did, AtUri, Datetime, UriValue};
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::space_polymodel::library;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Actor<S: BosStr = DefaultStr> {
    ///Avatar image URL resolved by the app view (CDN).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<UriValue<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub did: Option<Did<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub handle: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Width:height aspect ratio of an image, for layout before the blob loads.

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

/// Axis-aligned bounding-box dimensions. ATProto has no float type, so x/y/z are decimal strings (e.g. 12.5) parsed to floats internally.

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


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Chunk<S: BosStr = DefaultStr> {
    pub blob: BlobRef<S>,
    pub offset: i64,
    pub size: 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 FeedItem<S: BosStr = DefaultStr> {
    pub thing: library::ThingViewBasic<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


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

/// Chunk-capable geometry manifest. Reassemble by concatenating chunks in offset order. Per-chunk integrity is the blob CID; offset+size make ordering explicit; digest verifies the fully reassembled file.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct File<S: BosStr = DefaultStr> {
    pub chunks: Vec<library::Chunk<S>>,
    ///hex digest of the fully reassembled file (sha256 by convention)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub digest: Option<S>,
    pub mime_type: S,
    pub size: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// An authored image: a blob plus alt text and aspect ratio. Stored on records; the app view resolves it to #imageView.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Image<S: BosStr = DefaultStr> {
    ///Alt text describing the image, for accessibility.
    pub alt: S,
    pub aspect_ratio: library::AspectRatio<S>,
    pub image: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A resolved image view: CDN URLs for thumbnail and full size plus aspect ratio. Currently resolved via Bluesky's CDN by the app view.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ImageView<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alt: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aspect_ratio: Option<library::AspectRatio<S>>,
    ///Fully-qualified full-size URL (CDN, resolved by the app view).
    pub fullsize: UriValue<S>,
    ///Fully-qualified thumbnail URL (CDN, resolved by the app view).
    pub thumb: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ModelView<S: BosStr = DefaultStr> {
    pub author: library::Actor<S>,
    pub cid: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<Vec<library::ImageView<S>>>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub part_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previews: Option<Vec<library::ImageView<S>>>,
    pub record: Data<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<S>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<library::ViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct PartView<S: BosStr = DefaultStr> {
    pub author: library::Actor<S>,
    pub cid: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub file: Option<library::File<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub format: Option<S>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previews: Option<Vec<library::ImageView<S>>>,
    pub record: Data<S>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<library::ViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ThingView<S: BosStr = DefaultStr> {
    pub author: library::Actor<S>,
    pub cid: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<Vec<library::ImageView<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub derived_from: Option<StrongRef<S>>,
    pub indexed_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub intended_to_work_with: Option<Vec<StrongRef<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previews: Option<Vec<library::ImageView<S>>>,
    pub record: Data<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub save_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<S>>,
    pub uri: AtUri<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub viewer: Option<library::ViewerState<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ThingViewBasic<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub author: Option<library::Actor<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<Vec<library::ImageView<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_at: Option<Datetime>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub like_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model_count: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previews: Option<Vec<library::ImageView<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub save_count: Option<i64>,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


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

/// Reference-only shared field set; fields are inlined on thing/model.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct WorkMeta<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cover: Option<Vec<library::Image<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub derived_from: Option<StrongRef<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub instructions: Option<Vec<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub intended_to_work_with: Option<Vec<StrongRef<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previews: Option<Vec<library::Image<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Actor<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "actor"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for AspectRatio<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "aspectRatio"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Bbox<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "bbox"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Chunk<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "chunk"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.blob;
            {
                let size = value.blob().size;
                if size > 104857600usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("blob"),
                        max: 104857600usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.blob;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &[
                    "model/stl",
                    "model/3mf",
                    "model/obj",
                    "application/octet-stream",
                ];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("blob"),
                        accepted: vec![
                            "model/stl".to_string(), "model/3mf".to_string(), "model/obj"
                            .to_string(), "application/octet-stream".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        {
            let value = &self.offset;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("offset"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.size;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("size"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for FeedItem<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "feedItem"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for FeedView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "feedView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for File<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "file"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.chunks;
            #[allow(unused_comparisons)]
            if value.len() > 4096usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("chunks"),
                    max: 4096usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Image<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "image"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.alt;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("alt"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.alt;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 300usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("alt"),
                        max: 300usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.image;
            {
                let size = value.blob().size;
                if size > 5242880usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("image"),
                        max: 5242880usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.image;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg", "image/webp"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("image"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ImageView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "imageView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ModelView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "modelView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PartView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "partView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ThingView<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "thingView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ThingViewBasic<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "thingViewBasic"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ViewerState<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "viewerState"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for WorkMeta<S> {
    fn nsid() -> &'static str {
        "space.polymodel.library.defs"
    }
    fn def_name() -> &'static str {
        "workMeta"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_space_polymodel_library_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_space_polymodel_library_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("space.polymodel.library.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("actor"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avatar"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Avatar image URL resolved by the app view (CDN).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..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
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("aspectRatio"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Width:height aspect ratio of an image, for layout before the blob loads.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("height"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("width"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("bbox"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Axis-aligned bounding-box dimensions. ATProto has no float type, so x/y/z are decimal strings (e.g. 12.5) parsed to floats internally.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("x"), SmolStr::new_static("y"),
                            SmolStr::new_static("z")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("unit"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("x"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("y"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("z"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("chunk"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("blob"), SmolStr::new_static("offset"),
                            SmolStr::new_static("size")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("blob"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("offset"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("feedItem"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("thing")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("thing"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#thingViewBasic"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("feedView"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("items")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cursor"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("items"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#feedItem"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("file"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Chunk-capable geometry manifest. Reassemble by concatenating chunks in offset order. Per-chunk integrity is the blob CID; offset+size make ordering explicit; digest verifies the fully reassembled file.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("mimeType"), SmolStr::new_static("size"),
                            SmolStr::new_static("chunks")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("chunks"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#chunk"),
                                    ..Default::default()
                                }),
                                max_length: Some(4096usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "hex digest of the fully reassembled file (sha256 by convention)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("mimeType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("size"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("image"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "An authored image: a blob plus alt text and aspect ratio. Stored on records; the app view resolves it to #imageView.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("image"), SmolStr::new_static("alt"),
                            SmolStr::new_static("aspectRatio")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Alt text describing the image, for accessibility.",
                                    ),
                                ),
                                max_length: Some(2000usize),
                                max_graphemes: Some(300usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("aspectRatio"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#aspectRatio"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("image"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("imageView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A resolved image view: CDN URLs for thumbnail and full size plus aspect ratio. Currently resolved via Bluesky's CDN by the app view.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("thumb"), SmolStr::new_static("fullsize")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("aspectRatio"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#aspectRatio"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("fullsize"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Fully-qualified full-size URL (CDN, resolved by the app view).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("thumb"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Fully-qualified thumbnail URL (CDN, resolved by the app view).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("modelView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("record"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#actor"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("cover"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("partCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("previews"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#viewerState"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("partView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("record"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#actor"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("file"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#file"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("format"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("previews"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#viewerState"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("thingView"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("uri"), SmolStr::new_static("cid"),
                            SmolStr::new_static("author"), SmolStr::new_static("record"),
                            SmolStr::new_static("indexedAt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#actor"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("cover"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("derivedFrom"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("intendedToWorkWith"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("license"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("likeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("modelCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("previews"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("record"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("saveCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("tags"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("viewer"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#viewerState"),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("thingViewBasic"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#actor"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("cover"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("indexedAt"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("likeCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("modelCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("previews"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageView"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("saveCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("viewerState"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("like"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("save"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("workMeta"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Reference-only shared field set; fields are inlined on thing/model.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cover"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#image"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("derivedFrom"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("instructions"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("intendedToWorkWith"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("license"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("previews"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#image"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("tags"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> AspectRatio<S> {
    /// Create a new builder for this type
    pub fn builder() -> AspectRatioBuilder<aspect_ratio_state::Empty, S> {
        AspectRatioBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> AspectRatioBuilder<St, S>
where
    St: aspect_ratio_state::State,
    St::Width: aspect_ratio_state::IsUnset,
{
    /// Set the `width` field (required)
    pub fn width(
        mut self,
        value: impl Into<i64>,
    ) -> AspectRatioBuilder<aspect_ratio_state::SetWidth<St>, S> {
        self._fields.1 = Option::Some(value.into());
        AspectRatioBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> AspectRatioBuilder<St, S>
where
    St: aspect_ratio_state::State,
    St::Height: aspect_ratio_state::IsSet,
    St::Width: aspect_ratio_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> AspectRatio<S> {
        AspectRatio {
            height: self._fields.0.unwrap(),
            width: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> AspectRatio<S> {
        AspectRatio {
            height: self._fields.0.unwrap(),
            width: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod chunk_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 Blob;
        type Offset;
        type Size;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Blob = Unset;
        type Offset = Unset;
        type Size = Unset;
    }
    ///State transition - sets the `blob` field to Set
    pub struct SetBlob<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBlob<St> {}
    impl<St: State> State for SetBlob<St> {
        type Blob = Set<members::blob>;
        type Offset = St::Offset;
        type Size = St::Size;
    }
    ///State transition - sets the `offset` field to Set
    pub struct SetOffset<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOffset<St> {}
    impl<St: State> State for SetOffset<St> {
        type Blob = St::Blob;
        type Offset = Set<members::offset>;
        type Size = St::Size;
    }
    ///State transition - sets the `size` field to Set
    pub struct SetSize<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSize<St> {}
    impl<St: State> State for SetSize<St> {
        type Blob = St::Blob;
        type Offset = St::Offset;
        type Size = Set<members::size>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `blob` field
        pub struct blob(());
        ///Marker type for the `offset` field
        pub struct offset(());
        ///Marker type for the `size` field
        pub struct size(());
    }
}

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

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

impl<S: BosStr> Chunk<S> {
    /// Create a new builder for this type
    pub fn builder() -> ChunkBuilder<chunk_state::Empty, S> {
        ChunkBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ChunkBuilder<St, S>
where
    St: chunk_state::State,
    St::Blob: chunk_state::IsUnset,
{
    /// Set the `blob` field (required)
    pub fn blob(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> ChunkBuilder<chunk_state::SetBlob<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ChunkBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ChunkBuilder<St, S>
where
    St: chunk_state::State,
    St::Offset: chunk_state::IsUnset,
{
    /// Set the `offset` field (required)
    pub fn offset(
        mut self,
        value: impl Into<i64>,
    ) -> ChunkBuilder<chunk_state::SetOffset<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ChunkBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ChunkBuilder<St, S>
where
    St: chunk_state::State,
    St::Size: chunk_state::IsUnset,
{
    /// Set the `size` field (required)
    pub fn size(
        mut self,
        value: impl Into<i64>,
    ) -> ChunkBuilder<chunk_state::SetSize<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ChunkBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ChunkBuilder<St, S>
where
    St: chunk_state::State,
    St::Blob: chunk_state::IsSet,
    St::Offset: chunk_state::IsSet,
    St::Size: chunk_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Chunk<S> {
        Chunk {
            blob: self._fields.0.unwrap(),
            offset: self._fields.1.unwrap(),
            size: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Chunk<S> {
        Chunk {
            blob: self._fields.0.unwrap(),
            offset: self._fields.1.unwrap(),
            size: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> FeedItem<S> {
    /// Create a new builder for this type
    pub fn builder() -> FeedItemBuilder<feed_item_state::Empty, S> {
        FeedItemBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> FeedItemBuilder<St, S>
where
    St: feed_item_state::State,
    St::Thing: feed_item_state::IsUnset,
{
    /// Set the `thing` field (required)
    pub fn thing(
        mut self,
        value: impl Into<library::ThingViewBasic<S>>,
    ) -> FeedItemBuilder<feed_item_state::SetThing<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FeedItemBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

pub mod feed_view_state {

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

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

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

impl<S: BosStr> FeedView<S> {
    /// Create a new builder for this type
    pub fn builder() -> FeedViewBuilder<feed_view_state::Empty, S> {
        FeedViewBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> FeedViewBuilder<St, S>
where
    St: feed_view_state::State,
    St::Items: feed_view_state::IsUnset,
{
    /// Set the `items` field (required)
    pub fn items(
        mut self,
        value: impl Into<Vec<library::FeedItem<S>>>,
    ) -> FeedViewBuilder<feed_view_state::SetItems<St>, S> {
        self._fields.1 = Option::Some(value.into());
        FeedViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FeedViewBuilder<St, S>
where
    St: feed_view_state::State,
    St::Items: feed_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> FeedView<S> {
        FeedView {
            cursor: self._fields.0,
            items: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> FeedView<S> {
        FeedView {
            cursor: self._fields.0,
            items: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod file_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 Chunks;
        type MimeType;
        type Size;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Chunks = Unset;
        type MimeType = Unset;
        type Size = Unset;
    }
    ///State transition - sets the `chunks` field to Set
    pub struct SetChunks<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetChunks<St> {}
    impl<St: State> State for SetChunks<St> {
        type Chunks = Set<members::chunks>;
        type MimeType = St::MimeType;
        type Size = St::Size;
    }
    ///State transition - sets the `mime_type` field to Set
    pub struct SetMimeType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMimeType<St> {}
    impl<St: State> State for SetMimeType<St> {
        type Chunks = St::Chunks;
        type MimeType = Set<members::mime_type>;
        type Size = St::Size;
    }
    ///State transition - sets the `size` field to Set
    pub struct SetSize<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSize<St> {}
    impl<St: State> State for SetSize<St> {
        type Chunks = St::Chunks;
        type MimeType = St::MimeType;
        type Size = Set<members::size>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `chunks` field
        pub struct chunks(());
        ///Marker type for the `mime_type` field
        pub struct mime_type(());
        ///Marker type for the `size` field
        pub struct size(());
    }
}

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

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

impl<S: BosStr> File<S> {
    /// Create a new builder for this type
    pub fn builder() -> FileBuilder<file_state::Empty, S> {
        FileBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> FileBuilder<St, S>
where
    St: file_state::State,
    St::Chunks: file_state::IsUnset,
{
    /// Set the `chunks` field (required)
    pub fn chunks(
        mut self,
        value: impl Into<Vec<library::Chunk<S>>>,
    ) -> FileBuilder<file_state::SetChunks<St>, S> {
        self._fields.0 = Option::Some(value.into());
        FileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: file_state::State, S: BosStr> FileBuilder<St, S> {
    /// Set the `digest` field (optional)
    pub fn digest(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `digest` field to an Option value (optional)
    pub fn maybe_digest(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> FileBuilder<St, S>
where
    St: file_state::State,
    St::MimeType: file_state::IsUnset,
{
    /// Set the `mimeType` field (required)
    pub fn mime_type(
        mut self,
        value: impl Into<S>,
    ) -> FileBuilder<file_state::SetMimeType<St>, S> {
        self._fields.2 = Option::Some(value.into());
        FileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FileBuilder<St, S>
where
    St: file_state::State,
    St::Size: file_state::IsUnset,
{
    /// Set the `size` field (required)
    pub fn size(
        mut self,
        value: impl Into<i64>,
    ) -> FileBuilder<file_state::SetSize<St>, S> {
        self._fields.3 = Option::Some(value.into());
        FileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> FileBuilder<St, S>
where
    St: file_state::State,
    St::Chunks: file_state::IsSet,
    St::MimeType: file_state::IsSet,
    St::Size: file_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> File<S> {
        File {
            chunks: self._fields.0.unwrap(),
            digest: self._fields.1,
            mime_type: self._fields.2.unwrap(),
            size: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> File<S> {
        File {
            chunks: self._fields.0.unwrap(),
            digest: self._fields.1,
            mime_type: self._fields.2.unwrap(),
            size: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod image_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 Alt;
        type AspectRatio;
        type Image;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Alt = Unset;
        type AspectRatio = Unset;
        type Image = Unset;
    }
    ///State transition - sets the `alt` field to Set
    pub struct SetAlt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAlt<St> {}
    impl<St: State> State for SetAlt<St> {
        type Alt = Set<members::alt>;
        type AspectRatio = St::AspectRatio;
        type Image = St::Image;
    }
    ///State transition - sets the `aspect_ratio` field to Set
    pub struct SetAspectRatio<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAspectRatio<St> {}
    impl<St: State> State for SetAspectRatio<St> {
        type Alt = St::Alt;
        type AspectRatio = Set<members::aspect_ratio>;
        type Image = St::Image;
    }
    ///State transition - sets the `image` field to Set
    pub struct SetImage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetImage<St> {}
    impl<St: State> State for SetImage<St> {
        type Alt = St::Alt;
        type AspectRatio = St::AspectRatio;
        type Image = Set<members::image>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `alt` field
        pub struct alt(());
        ///Marker type for the `aspect_ratio` field
        pub struct aspect_ratio(());
        ///Marker type for the `image` field
        pub struct image(());
    }
}

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

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

impl<S: BosStr> Image<S> {
    /// Create a new builder for this type
    pub fn builder() -> ImageBuilder<image_state::Empty, S> {
        ImageBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ImageBuilder<St, S>
where
    St: image_state::State,
    St::Alt: image_state::IsUnset,
{
    /// Set the `alt` field (required)
    pub fn alt(
        mut self,
        value: impl Into<S>,
    ) -> ImageBuilder<image_state::SetAlt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageBuilder<St, S>
where
    St: image_state::State,
    St::AspectRatio: image_state::IsUnset,
{
    /// Set the `aspectRatio` field (required)
    pub fn aspect_ratio(
        mut self,
        value: impl Into<library::AspectRatio<S>>,
    ) -> ImageBuilder<image_state::SetAspectRatio<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageBuilder<St, S>
where
    St: image_state::State,
    St::Image: image_state::IsUnset,
{
    /// Set the `image` field (required)
    pub fn image(
        mut self,
        value: impl Into<BlobRef<S>>,
    ) -> ImageBuilder<image_state::SetImage<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ImageBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageBuilder<St, S>
where
    St: image_state::State,
    St::Alt: image_state::IsSet,
    St::AspectRatio: image_state::IsSet,
    St::Image: image_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Image<S> {
        Image {
            alt: self._fields.0.unwrap(),
            aspect_ratio: self._fields.1.unwrap(),
            image: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Image<S> {
        Image {
            alt: self._fields.0.unwrap(),
            aspect_ratio: self._fields.1.unwrap(),
            image: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod image_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Fullsize;
        type Thumb;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Fullsize = Unset;
        type Thumb = Unset;
    }
    ///State transition - sets the `fullsize` field to Set
    pub struct SetFullsize<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFullsize<St> {}
    impl<St: State> State for SetFullsize<St> {
        type Fullsize = Set<members::fullsize>;
        type Thumb = St::Thumb;
    }
    ///State transition - sets the `thumb` field to Set
    pub struct SetThumb<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetThumb<St> {}
    impl<St: State> State for SetThumb<St> {
        type Fullsize = St::Fullsize;
        type Thumb = Set<members::thumb>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `fullsize` field
        pub struct fullsize(());
        ///Marker type for the `thumb` field
        pub struct thumb(());
    }
}

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

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

impl<S: BosStr> ImageView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ImageViewBuilder<image_view_state::Empty, S> {
        ImageViewBuilder::builder()
    }
}

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

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

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

impl<St: image_view_state::State, S: BosStr> ImageViewBuilder<St, S> {
    /// Set the `aspectRatio` field (optional)
    pub fn aspect_ratio(
        mut self,
        value: impl Into<Option<library::AspectRatio<S>>>,
    ) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `aspectRatio` field to an Option value (optional)
    pub fn maybe_aspect_ratio(mut self, value: Option<library::AspectRatio<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> ImageViewBuilder<St, S>
where
    St: image_view_state::State,
    St::Fullsize: image_view_state::IsUnset,
{
    /// Set the `fullsize` field (required)
    pub fn fullsize(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> ImageViewBuilder<image_view_state::SetFullsize<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ImageViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageViewBuilder<St, S>
where
    St: image_view_state::State,
    St::Thumb: image_view_state::IsUnset,
{
    /// Set the `thumb` field (required)
    pub fn thumb(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> ImageViewBuilder<image_view_state::SetThumb<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ImageViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageViewBuilder<St, S>
where
    St: image_view_state::State,
    St::Fullsize: image_view_state::IsSet,
    St::Thumb: image_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ImageView<S> {
        ImageView {
            alt: self._fields.0,
            aspect_ratio: self._fields.1,
            fullsize: self._fields.2.unwrap(),
            thumb: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ImageView<S> {
        ImageView {
            alt: self._fields.0,
            aspect_ratio: self._fields.1,
            fullsize: self._fields.2.unwrap(),
            thumb: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod model_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Author;
        type Cid;
        type IndexedAt;
        type Record;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type Record = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = Set<members::record>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `record` field
        pub struct record(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ModelViewBuilder<St: model_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<library::Actor<S>>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<Datetime>,
        Option<S>,
        Option<i64>,
        Option<Vec<library::ImageView<S>>>,
        Option<Data<S>>,
        Option<S>,
        Option<AtUri<S>>,
        Option<library::ViewerState<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ModelView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ModelViewBuilder<model_view_state::Empty, S> {
        ModelViewBuilder::builder()
    }
}

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

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

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

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

impl<St: model_view_state::State, S: BosStr> ModelViewBuilder<St, S> {
    /// Set the `cover` field (optional)
    pub fn cover(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<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<Vec<library::ImageView<S>>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<St: model_view_state::State, S: BosStr> ModelViewBuilder<St, S> {
    /// Set the `partCount` field (optional)
    pub fn part_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `partCount` field to an Option value (optional)
    pub fn maybe_part_count(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: model_view_state::State, S: BosStr> ModelViewBuilder<St, S> {
    /// Set the `previews` field (optional)
    pub fn previews(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<S>>>>,
    ) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `previews` field to an Option value (optional)
    pub fn maybe_previews(mut self, value: Option<Vec<library::ImageView<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

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

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

impl<St: model_view_state::State, S: BosStr> ModelViewBuilder<St, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(mut self, value: impl Into<Option<library::ViewerState<S>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `viewer` field to an Option value (optional)
    pub fn maybe_viewer(mut self, value: Option<library::ViewerState<S>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> ModelViewBuilder<St, S>
where
    St: model_view_state::State,
    St::Author: model_view_state::IsSet,
    St::Cid: model_view_state::IsSet,
    St::IndexedAt: model_view_state::IsSet,
    St::Record: model_view_state::IsSet,
    St::Uri: model_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ModelView<S> {
        ModelView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            cover: self._fields.2,
            indexed_at: self._fields.3.unwrap(),
            name: self._fields.4,
            part_count: self._fields.5,
            previews: self._fields.6,
            record: self._fields.7.unwrap(),
            summary: self._fields.8,
            uri: self._fields.9.unwrap(),
            viewer: self._fields.10,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ModelView<S> {
        ModelView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            cover: self._fields.2,
            indexed_at: self._fields.3.unwrap(),
            name: self._fields.4,
            part_count: self._fields.5,
            previews: self._fields.6,
            record: self._fields.7.unwrap(),
            summary: self._fields.8,
            uri: self._fields.9.unwrap(),
            viewer: self._fields.10,
            extra_data: Some(extra_data),
        }
    }
}

pub mod part_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Author;
        type Cid;
        type IndexedAt;
        type Record;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type Record = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = Set<members::record>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `record` field
        pub struct record(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct PartViewBuilder<St: part_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<library::Actor<S>>,
        Option<S>,
        Option<library::File<S>>,
        Option<S>,
        Option<Datetime>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<Data<S>>,
        Option<AtUri<S>>,
        Option<library::ViewerState<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> PartView<S> {
    /// Create a new builder for this type
    pub fn builder() -> PartViewBuilder<part_view_state::Empty, S> {
        PartViewBuilder::builder()
    }
}

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

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

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

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

impl<St: part_view_state::State, S: BosStr> PartViewBuilder<St, S> {
    /// Set the `file` field (optional)
    pub fn file(mut self, value: impl Into<Option<library::File<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `file` field to an Option value (optional)
    pub fn maybe_file(mut self, value: Option<library::File<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

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

impl<St: part_view_state::State, S: BosStr> PartViewBuilder<St, S> {
    /// Set the `previews` field (optional)
    pub fn previews(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<S>>>>,
    ) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `previews` field to an Option value (optional)
    pub fn maybe_previews(mut self, value: Option<Vec<library::ImageView<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

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

impl<St: part_view_state::State, S: BosStr> PartViewBuilder<St, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(mut self, value: impl Into<Option<library::ViewerState<S>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `viewer` field to an Option value (optional)
    pub fn maybe_viewer(mut self, value: Option<library::ViewerState<S>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> PartViewBuilder<St, S>
where
    St: part_view_state::State,
    St::Author: part_view_state::IsSet,
    St::Cid: part_view_state::IsSet,
    St::IndexedAt: part_view_state::IsSet,
    St::Record: part_view_state::IsSet,
    St::Uri: part_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> PartView<S> {
        PartView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            file: self._fields.2,
            format: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            name: self._fields.5,
            previews: self._fields.6,
            record: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer: self._fields.9,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> PartView<S> {
        PartView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            file: self._fields.2,
            format: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            name: self._fields.5,
            previews: self._fields.6,
            record: self._fields.7.unwrap(),
            uri: self._fields.8.unwrap(),
            viewer: self._fields.9,
            extra_data: Some(extra_data),
        }
    }
}

pub mod thing_view_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Author;
        type Cid;
        type IndexedAt;
        type Record;
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Author = Unset;
        type Cid = Unset;
        type IndexedAt = Unset;
        type Record = Unset;
        type Uri = Unset;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAuthor<St> {}
    impl<St: State> State for SetAuthor<St> {
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCid<St> {}
    impl<St: State> State for SetCid<St> {
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `indexed_at` field to Set
    pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
    impl<St: State> State for SetIndexedAt<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = Set<members::indexed_at>;
        type Record = St::Record;
        type Uri = St::Uri;
    }
    ///State transition - sets the `record` field to Set
    pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRecord<St> {}
    impl<St: State> State for SetRecord<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = Set<members::record>;
        type Uri = St::Uri;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUri<St> {}
    impl<St: State> State for SetUri<St> {
        type Author = St::Author;
        type Cid = St::Cid;
        type IndexedAt = St::IndexedAt;
        type Record = St::Record;
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `indexed_at` field
        pub struct indexed_at(());
        ///Marker type for the `record` field
        pub struct record(());
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ThingViewBuilder<St: thing_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<library::Actor<S>>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<StrongRef<S>>,
        Option<Datetime>,
        Option<Vec<StrongRef<S>>>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<Data<S>>,
        Option<i64>,
        Option<S>,
        Option<Vec<S>>,
        Option<AtUri<S>>,
        Option<library::ViewerState<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ThingView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ThingViewBuilder<thing_view_state::Empty, S> {
        ThingViewBuilder::builder()
    }
}

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

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

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

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `cover` field (optional)
    pub fn cover(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<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<Vec<library::ImageView<S>>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `derivedFrom` field (optional)
    pub fn derived_from(mut self, value: impl Into<Option<StrongRef<S>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `derivedFrom` field to an Option value (optional)
    pub fn maybe_derived_from(mut self, value: Option<StrongRef<S>>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `intendedToWorkWith` field (optional)
    pub fn intended_to_work_with(
        mut self,
        value: impl Into<Option<Vec<StrongRef<S>>>>,
    ) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `intendedToWorkWith` field to an Option value (optional)
    pub fn maybe_intended_to_work_with(
        mut self,
        value: Option<Vec<StrongRef<S>>>,
    ) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `license` field (optional)
    pub fn license(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `license` field to an Option value (optional)
    pub fn maybe_license(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `modelCount` field (optional)
    pub fn model_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `modelCount` field to an Option value (optional)
    pub fn maybe_model_count(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `previews` field (optional)
    pub fn previews(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<S>>>>,
    ) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `previews` field to an Option value (optional)
    pub fn maybe_previews(mut self, value: Option<Vec<library::ImageView<S>>>) -> Self {
        self._fields.10 = value;
        self
    }
}

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `saveCount` field (optional)
    pub fn save_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `saveCount` field to an Option value (optional)
    pub fn maybe_save_count(mut self, value: Option<i64>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `summary` field (optional)
    pub fn summary(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `summary` field to an Option value (optional)
    pub fn maybe_summary(mut self, value: Option<S>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `tags` field (optional)
    pub fn tags(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `tags` field to an Option value (optional)
    pub fn maybe_tags(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.14 = value;
        self
    }
}

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

impl<St: thing_view_state::State, S: BosStr> ThingViewBuilder<St, S> {
    /// Set the `viewer` field (optional)
    pub fn viewer(mut self, value: impl Into<Option<library::ViewerState<S>>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `viewer` field to an Option value (optional)
    pub fn maybe_viewer(mut self, value: Option<library::ViewerState<S>>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St, S: BosStr> ThingViewBuilder<St, S>
where
    St: thing_view_state::State,
    St::Author: thing_view_state::IsSet,
    St::Cid: thing_view_state::IsSet,
    St::IndexedAt: thing_view_state::IsSet,
    St::Record: thing_view_state::IsSet,
    St::Uri: thing_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ThingView<S> {
        ThingView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            cover: self._fields.2,
            derived_from: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            intended_to_work_with: self._fields.5,
            license: self._fields.6,
            like_count: self._fields.7,
            model_count: self._fields.8,
            name: self._fields.9,
            previews: self._fields.10,
            record: self._fields.11.unwrap(),
            save_count: self._fields.12,
            summary: self._fields.13,
            tags: self._fields.14,
            uri: self._fields.15.unwrap(),
            viewer: self._fields.16,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ThingView<S> {
        ThingView {
            author: self._fields.0.unwrap(),
            cid: self._fields.1.unwrap(),
            cover: self._fields.2,
            derived_from: self._fields.3,
            indexed_at: self._fields.4.unwrap(),
            intended_to_work_with: self._fields.5,
            license: self._fields.6,
            like_count: self._fields.7,
            model_count: self._fields.8,
            name: self._fields.9,
            previews: self._fields.10,
            record: self._fields.11.unwrap(),
            save_count: self._fields.12,
            summary: self._fields.13,
            tags: self._fields.14,
            uri: self._fields.15.unwrap(),
            viewer: self._fields.16,
            extra_data: Some(extra_data),
        }
    }
}

pub mod thing_view_basic_state {

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

/// Builder for constructing an instance of this type.
pub struct ThingViewBasicBuilder<
    St: thing_view_basic_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<library::Actor<S>>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<Datetime>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<Vec<library::ImageView<S>>>,
        Option<i64>,
        Option<AtUri<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ThingViewBasic<S> {
    /// Create a new builder for this type
    pub fn builder() -> ThingViewBasicBuilder<thing_view_basic_state::Empty, S> {
        ThingViewBasicBuilder::builder()
    }
}

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

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

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `author` field (optional)
    pub fn author(mut self, value: impl Into<Option<library::Actor<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `author` field to an Option value (optional)
    pub fn maybe_author(mut self, value: Option<library::Actor<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `cid` field (optional)
    pub fn cid(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `cid` field to an Option value (optional)
    pub fn maybe_cid(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `cover` field (optional)
    pub fn cover(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<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<Vec<library::ImageView<S>>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `indexedAt` field (optional)
    pub fn indexed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `indexedAt` field to an Option value (optional)
    pub fn maybe_indexed_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `modelCount` field (optional)
    pub fn model_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `modelCount` field to an Option value (optional)
    pub fn maybe_model_count(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

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

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `previews` field (optional)
    pub fn previews(
        mut self,
        value: impl Into<Option<Vec<library::ImageView<S>>>>,
    ) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `previews` field to an Option value (optional)
    pub fn maybe_previews(mut self, value: Option<Vec<library::ImageView<S>>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: thing_view_basic_state::State, S: BosStr> ThingViewBasicBuilder<St, S> {
    /// Set the `saveCount` field (optional)
    pub fn save_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `saveCount` field to an Option value (optional)
    pub fn maybe_save_count(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

impl<St, S: BosStr> ThingViewBasicBuilder<St, S>
where
    St: thing_view_basic_state::State,
    St::Uri: thing_view_basic_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ThingViewBasic<S> {
        ThingViewBasic {
            author: self._fields.0,
            cid: self._fields.1,
            cover: self._fields.2,
            indexed_at: self._fields.3,
            like_count: self._fields.4,
            model_count: self._fields.5,
            name: self._fields.6,
            previews: self._fields.7,
            save_count: self._fields.8,
            uri: self._fields.9.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>>,
    ) -> ThingViewBasic<S> {
        ThingViewBasic {
            author: self._fields.0,
            cid: self._fields.1,
            cover: self._fields.2,
            indexed_at: self._fields.3,
            like_count: self._fields.4,
            model_count: self._fields.5,
            name: self._fields.6,
            previews: self._fields.7,
            save_count: self._fields.8,
            uri: self._fields.9.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}