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

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Author<'a> {
    ///The DID of the author
    #[serde(borrow)]
    pub did: Did<'a>,
    ///The handle of the author.
    #[serde(borrow)]
    pub handle: Handle<'a>,
}

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct HydratedOekaki<'a> {
    ///Alt text description of the image, for accessibility.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub alt: Option<CowStr<'a>>,
    ///The AT protocol link.
    #[serde(borrow)]
    pub at: UriValue<'a>,
    #[serde(borrow)]
    pub author: app_view_defs::Author<'a>,
    ///The oekaki CID.
    #[serde(borrow)]
    pub cid: Cid<'a>,
    ///The creation time.
    pub creation_time: Datetime,
    ///The image link.
    #[serde(borrow)]
    pub image: UriValue<'a>,
    ///Is this oekaki NSFW?
    pub nsfw: bool,
    ///An array of tags this image had.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub tags: Option<Vec<CowStr<'a>>>,
}

/// A tombstone for a missing oekaki.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct OekakiTombstone<'a> {
    ///The AT uri of the former oekaki.
    #[serde(borrow)]
    pub former_at: AtUri<'a>,
}

impl<'a> LexiconSchema for Author<'a> {
    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<'a> LexiconSchema for HydratedOekaki<'a> {
    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<'a> LexiconSchema for OekakiTombstone<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDid<S> {}
    impl<S: State> State for SetDid<S> {
        type Did = Set<members::did>;
        type Handle = S::Handle;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHandle<S> {}
    impl<S: State> State for SetHandle<S> {
        type Did = S::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<'a, S: author_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Did<'a>>, Option<Handle<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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

impl<'a, S> AuthorBuilder<'a, S>
where
    S: author_state::State,
    S::Did: author_state::IsSet,
    S::Handle: author_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Author<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Author<'a> {
        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 Nsfw;
        type Cid;
        type Image;
        type Author;
        type CreationTime;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type At = Unset;
        type Nsfw = Unset;
        type Cid = Unset;
        type Image = Unset;
        type Author = Unset;
        type CreationTime = Unset;
    }
    ///State transition - sets the `at` field to Set
    pub struct SetAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAt<S> {}
    impl<S: State> State for SetAt<S> {
        type At = Set<members::at>;
        type Nsfw = S::Nsfw;
        type Cid = S::Cid;
        type Image = S::Image;
        type Author = S::Author;
        type CreationTime = S::CreationTime;
    }
    ///State transition - sets the `nsfw` field to Set
    pub struct SetNsfw<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetNsfw<S> {}
    impl<S: State> State for SetNsfw<S> {
        type At = S::At;
        type Nsfw = Set<members::nsfw>;
        type Cid = S::Cid;
        type Image = S::Image;
        type Author = S::Author;
        type CreationTime = S::CreationTime;
    }
    ///State transition - sets the `cid` field to Set
    pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCid<S> {}
    impl<S: State> State for SetCid<S> {
        type At = S::At;
        type Nsfw = S::Nsfw;
        type Cid = Set<members::cid>;
        type Image = S::Image;
        type Author = S::Author;
        type CreationTime = S::CreationTime;
    }
    ///State transition - sets the `image` field to Set
    pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetImage<S> {}
    impl<S: State> State for SetImage<S> {
        type At = S::At;
        type Nsfw = S::Nsfw;
        type Cid = S::Cid;
        type Image = Set<members::image>;
        type Author = S::Author;
        type CreationTime = S::CreationTime;
    }
    ///State transition - sets the `author` field to Set
    pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAuthor<S> {}
    impl<S: State> State for SetAuthor<S> {
        type At = S::At;
        type Nsfw = S::Nsfw;
        type Cid = S::Cid;
        type Image = S::Image;
        type Author = Set<members::author>;
        type CreationTime = S::CreationTime;
    }
    ///State transition - sets the `creation_time` field to Set
    pub struct SetCreationTime<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreationTime<S> {}
    impl<S: State> State for SetCreationTime<S> {
        type At = S::At;
        type Nsfw = S::Nsfw;
        type Cid = S::Cid;
        type Image = S::Image;
        type Author = S::Author;
        type CreationTime = Set<members::creation_time>;
    }
    /// 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 `nsfw` field
        pub struct nsfw(());
        ///Marker type for the `cid` field
        pub struct cid(());
        ///Marker type for the `image` field
        pub struct image(());
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `creation_time` field
        pub struct creation_time(());
    }
}

/// Builder for constructing an instance of this type
pub struct HydratedOekakiBuilder<'a, S: hydrated_oekaki_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<app_view_defs::Author<'a>>,
        Option<Cid<'a>>,
        Option<Datetime>,
        Option<UriValue<'a>>,
        Option<bool>,
        Option<Vec<CowStr<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> HydratedOekakiBuilder<'a, S>
where
    S: hydrated_oekaki_state::State,
    S::At: hydrated_oekaki_state::IsUnset,
{
    /// Set the `at` field (required)
    pub fn at(
        mut self,
        value: impl Into<UriValue<'a>>,
    ) -> HydratedOekakiBuilder<'a, hydrated_oekaki_state::SetAt<S>> {
        self._fields.1 = Option::Some(value.into());
        HydratedOekakiBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

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

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

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

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

impl<'a, S> HydratedOekakiBuilder<'a, S>
where
    S: hydrated_oekaki_state::State,
    S::At: hydrated_oekaki_state::IsSet,
    S::Nsfw: hydrated_oekaki_state::IsSet,
    S::Cid: hydrated_oekaki_state::IsSet,
    S::Image: hydrated_oekaki_state::IsSet,
    S::Author: hydrated_oekaki_state::IsSet,
    S::CreationTime: hydrated_oekaki_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> HydratedOekaki<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> HydratedOekaki<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFormerAt<S> {}
    impl<S: State> State for SetFormerAt<S> {
        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<'a, S: oekaki_tombstone_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<AtUri<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> OekakiTombstoneBuilder<'a, S>
where
    S: oekaki_tombstone_state::State,
    S::FormerAt: oekaki_tombstone_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> OekakiTombstone<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> OekakiTombstone<'a> {
        OekakiTombstone {
            former_at: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}