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

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Handle, AtUri, Cid, 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_shinolabs::pinksea::app_view_defs;
/// An author for an oekaki post

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Author<S: BosStr = DefaultStr> {
    ///The DID of the author
    pub did: Did<S>,
    ///The handle of the author.
    pub handle: Handle<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A hydrated oekaki post returned from the PinkSea app view.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct HydratedOekaki<S: BosStr = DefaultStr> {
    ///Alt text description of the image, for accessibility.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alt: Option<S>,
    ///The AT protocol link.
    pub at: UriValue<S>,
    pub author: app_view_defs::Author<S>,
    ///The oekaki CID.
    pub cid: Cid<S>,
    ///The creation time.
    pub creation_time: Datetime,
    ///The image link.
    pub image: UriValue<S>,
    ///Is this oekaki NSFW?
    pub nsfw: bool,
    ///An array of tags this image had.
    #[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>>>,
}

/// A tombstone for a missing oekaki.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct OekakiTombstone<S: BosStr = DefaultStr> {
    ///The AT uri of the former oekaki.
    pub former_at: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Author<S> {
    fn nsid() -> &'static str {
        "com.shinolabs.pinksea.appViewDefs"
    }
    fn def_name() -> &'static str {
        "author"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_shinolabs_pinksea_appViewDefs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for HydratedOekaki<S> {
    fn nsid() -> &'static str {
        "com.shinolabs.pinksea.appViewDefs"
    }
    fn def_name() -> &'static str {
        "hydratedOekaki"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_shinolabs_pinksea_appViewDefs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.tags {
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tags"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for OekakiTombstone<S> {
    fn nsid() -> &'static str {
        "com.shinolabs.pinksea.appViewDefs"
    }
    fn def_name() -> &'static str {
        "oekakiTombstone"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_shinolabs_pinksea_appViewDefs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> Author<S> {
    /// Create a new builder for this type
    pub fn builder() -> AuthorBuilder<author_state::Empty, S> {
        AuthorBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> AuthorBuilder<St, S>
where
    St: author_state::State,
    St::Did: author_state::IsSet,
    St::Handle: author_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Author<S> {
        Author {
            did: self._fields.0.unwrap(),
            handle: 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>>) -> Author<S> {
        Author {
            did: self._fields.0.unwrap(),
            handle: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_com_shinolabs_pinksea_appViewDefs() -> 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("com.shinolabs.pinksea.appViewDefs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("author"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("An author for an oekaki post"),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The DID of the author"),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("handle"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The handle of the author."),
                                ),
                                format: Some(LexStringFormat::Handle),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("hydratedOekaki"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A hydrated oekaki post returned from the PinkSea app view.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("author"), SmolStr::new_static("image"),
                            SmolStr::new_static("at"), SmolStr::new_static("cid"),
                            SmolStr::new_static("creationTime"),
                            SmolStr::new_static("nsfw")
                        ],
                    ),
                    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 description of the image, for accessibility.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("at"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The AT protocol link."),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("author"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#author"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The oekaki CID.")),
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("creationTime"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The creation time.")),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("image"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("The image link.")),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("nsfw"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("An array of tags this image had."),
                                ),
                                items: LexArrayItem::String(LexString {
                                    max_length: Some(640usize),
                                    ..Default::default()
                                }),
                                max_length: Some(10usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("oekakiTombstone"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("A tombstone for a missing oekaki."),
                    ),
                    required: Some(vec![SmolStr::new_static("formerAt")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("formerAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The AT uri of the former oekaki."),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod hydrated_oekaki_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 At;
        type Author;
        type Cid;
        type CreationTime;
        type Image;
        type Nsfw;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type At = Unset;
        type Author = Unset;
        type Cid = Unset;
        type CreationTime = Unset;
        type Image = Unset;
        type Nsfw = Unset;
    }
    ///State transition - sets the `at` field to Set
    pub struct SetAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetAt<St> {}
    impl<St: State> State for SetAt<St> {
        type At = Set<members::at>;
        type Author = St::Author;
        type Cid = St::Cid;
        type CreationTime = St::CreationTime;
        type Image = St::Image;
        type Nsfw = St::Nsfw;
    }
    ///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 At = St::At;
        type Author = Set<members::author>;
        type Cid = St::Cid;
        type CreationTime = St::CreationTime;
        type Image = St::Image;
        type Nsfw = St::Nsfw;
    }
    ///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 At = St::At;
        type Author = St::Author;
        type Cid = Set<members::cid>;
        type CreationTime = St::CreationTime;
        type Image = St::Image;
        type Nsfw = St::Nsfw;
    }
    ///State transition - sets the `creation_time` field to Set
    pub struct SetCreationTime<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreationTime<St> {}
    impl<St: State> State for SetCreationTime<St> {
        type At = St::At;
        type Author = St::Author;
        type Cid = St::Cid;
        type CreationTime = Set<members::creation_time>;
        type Image = St::Image;
        type Nsfw = St::Nsfw;
    }
    ///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 At = St::At;
        type Author = St::Author;
        type Cid = St::Cid;
        type CreationTime = St::CreationTime;
        type Image = Set<members::image>;
        type Nsfw = St::Nsfw;
    }
    ///State transition - sets the `nsfw` field to Set
    pub struct SetNsfw<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetNsfw<St> {}
    impl<St: State> State for SetNsfw<St> {
        type At = St::At;
        type Author = St::Author;
        type Cid = St::Cid;
        type CreationTime = St::CreationTime;
        type Image = St::Image;
        type Nsfw = Set<members::nsfw>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `at` field
        pub struct at(());
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `creation_time` field
        pub struct creation_time(());
        ///Marker type for the `image` field
        pub struct image(());
        ///Marker type for the `nsfw` field
        pub struct nsfw(());
    }
}

/// Builder for constructing an instance of this type.
pub struct HydratedOekakiBuilder<
    St: hydrated_oekaki_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<UriValue<S>>,
        Option<app_view_defs::Author<S>>,
        Option<Cid<S>>,
        Option<Datetime>,
        Option<UriValue<S>>,
        Option<bool>,
        Option<Vec<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> HydratedOekaki<S> {
    /// Create a new builder for this type
    pub fn builder() -> HydratedOekakiBuilder<hydrated_oekaki_state::Empty, S> {
        HydratedOekakiBuilder::builder()
    }
}

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

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

impl<St: hydrated_oekaki_state::State, S: BosStr> HydratedOekakiBuilder<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, S: BosStr> HydratedOekakiBuilder<St, S>
where
    St: hydrated_oekaki_state::State,
    St::At: hydrated_oekaki_state::IsUnset,
{
    /// Set the `at` field (required)
    pub fn at(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> HydratedOekakiBuilder<hydrated_oekaki_state::SetAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        HydratedOekakiBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> HydratedOekakiBuilder<St, S>
where
    St: hydrated_oekaki_state::State,
    St::CreationTime: hydrated_oekaki_state::IsUnset,
{
    /// Set the `creationTime` field (required)
    pub fn creation_time(
        mut self,
        value: impl Into<Datetime>,
    ) -> HydratedOekakiBuilder<hydrated_oekaki_state::SetCreationTime<St>, S> {
        self._fields.4 = Option::Some(value.into());
        HydratedOekakiBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> HydratedOekakiBuilder<St, S>
where
    St: hydrated_oekaki_state::State,
    St::Nsfw: hydrated_oekaki_state::IsUnset,
{
    /// Set the `nsfw` field (required)
    pub fn nsfw(
        mut self,
        value: impl Into<bool>,
    ) -> HydratedOekakiBuilder<hydrated_oekaki_state::SetNsfw<St>, S> {
        self._fields.6 = Option::Some(value.into());
        HydratedOekakiBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> HydratedOekakiBuilder<St, S>
where
    St: hydrated_oekaki_state::State,
    St::At: hydrated_oekaki_state::IsSet,
    St::Author: hydrated_oekaki_state::IsSet,
    St::Cid: hydrated_oekaki_state::IsSet,
    St::CreationTime: hydrated_oekaki_state::IsSet,
    St::Image: hydrated_oekaki_state::IsSet,
    St::Nsfw: hydrated_oekaki_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> HydratedOekaki<S> {
        HydratedOekaki {
            alt: self._fields.0,
            at: self._fields.1.unwrap(),
            author: self._fields.2.unwrap(),
            cid: self._fields.3.unwrap(),
            creation_time: self._fields.4.unwrap(),
            image: self._fields.5.unwrap(),
            nsfw: self._fields.6.unwrap(),
            tags: self._fields.7,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> HydratedOekaki<S> {
        HydratedOekaki {
            alt: self._fields.0,
            at: self._fields.1.unwrap(),
            author: self._fields.2.unwrap(),
            cid: self._fields.3.unwrap(),
            creation_time: self._fields.4.unwrap(),
            image: self._fields.5.unwrap(),
            nsfw: self._fields.6.unwrap(),
            tags: self._fields.7,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> OekakiTombstone<S> {
    /// Create a new builder for this type
    pub fn builder() -> OekakiTombstoneBuilder<oekaki_tombstone_state::Empty, S> {
        OekakiTombstoneBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> OekakiTombstoneBuilder<St, S>
where
    St: oekaki_tombstone_state::State,
    St::FormerAt: oekaki_tombstone_state::IsUnset,
{
    /// Set the `formerAt` field (required)
    pub fn former_at(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> OekakiTombstoneBuilder<oekaki_tombstone_state::SetFormerAt<St>, S> {
        self._fields.0 = Option::Some(value.into());
        OekakiTombstoneBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> OekakiTombstoneBuilder<St, S>
where
    St: oekaki_tombstone_state::State,
    St::FormerAt: oekaki_tombstone_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> OekakiTombstone<S> {
        OekakiTombstone {
            former_at: 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>>,
    ) -> OekakiTombstone<S> {
        OekakiTombstone {
            former_at: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}