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

//! Generated bindings for the `org.hypercerts` Lexicon namespace/module.
pub mod claim;
pub mod collection;
pub mod context;
pub mod funding;
pub mod helper;
pub mod workscope;


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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{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::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};
/// Object containing a blob to external data

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LargeBlob<S: BosStr = DefaultStr> {
    ///Blob to external data (up to 100MB)
    pub blob: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object containing a large image

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LargeImage<S: BosStr = DefaultStr> {
    ///Image (up to 10MB)
    pub image: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object containing a blob to external data

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SmallBlob<S: BosStr = DefaultStr> {
    ///Blob to external data (up to 10MB)
    pub blob: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object containing a small image

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SmallImage<S: BosStr = DefaultStr> {
    ///Image (up to 5MB)
    pub image: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object containing a small video

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SmallVideo<S: BosStr = DefaultStr> {
    ///Video (up to 20MB)
    pub video: BlobRef<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Object containing a URI to external data

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Uri<S: BosStr = DefaultStr> {
    ///URI to external data
    pub uri: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for LargeBlob<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "largeBlob"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_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] = &["*/*"];
                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!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LargeImage<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "largeImage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.image;
            {
                let size = value.blob().size;
                if size > 10485760usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("image"),
                        max: 10485760usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.image;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &[
                    "image/jpeg",
                    "image/jpg",
                    "image/png",
                    "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/jpeg".to_string(), "image/jpg".to_string(),
                            "image/png".to_string(), "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SmallBlob<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "smallBlob"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.blob;
            {
                let size = value.blob().size;
                if size > 10485760usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("blob"),
                        max: 10485760usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.blob;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["*/*"];
                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!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SmallImage<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "smallImage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            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/jpeg",
                    "image/jpg",
                    "image/png",
                    "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/jpeg".to_string(), "image/jpg".to_string(),
                            "image/png".to_string(), "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SmallVideo<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "smallVideo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.video;
            {
                let size = value.blob().size;
                if size > 20971520usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("video"),
                        max: 20971520usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.video;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["video/mp4", "video/webm"];
                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("video"),
                        accepted: vec![
                            "video/mp4".to_string(), "video/webm".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Uri<S> {
    fn nsid() -> &'static str {
        "org.hypercerts.defs"
    }
    fn def_name() -> &'static str {
        "uri"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_hypercerts_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod large_blob_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;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Blob = 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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `blob` field
        pub struct blob(());
    }
}

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

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

impl<S: BosStr> LargeBlob<S> {
    /// Create a new builder for this type
    pub fn builder() -> LargeBlobBuilder<large_blob_state::Empty, S> {
        LargeBlobBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LargeBlobBuilder<St, S>
where
    St: large_blob_state::State,
    St::Blob: large_blob_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LargeBlob<S> {
        LargeBlob {
            blob: 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>>,
    ) -> LargeBlob<S> {
        LargeBlob {
            blob: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_hypercerts_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("org.hypercerts.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("largeBlob"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a blob to external data"),
                    ),
                    required: Some(vec![SmolStr::new_static("blob")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("blob"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("largeImage"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a large image"),
                    ),
                    required: Some(vec![SmolStr::new_static("image")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("image"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("smallBlob"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a blob to external data"),
                    ),
                    required: Some(vec![SmolStr::new_static("blob")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("blob"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("smallImage"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a small image"),
                    ),
                    required: Some(vec![SmolStr::new_static("image")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("image"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("smallVideo"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a small video"),
                    ),
                    required: Some(vec![SmolStr::new_static("video")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("video"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("uri"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Object containing a URI to external data"),
                    ),
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("URI to external data"),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod large_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 Image;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Image = Unset;
    }
    ///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 Image = Set<members::image>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `image` field
        pub struct image(());
    }
}

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

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

impl<S: BosStr> LargeImage<S> {
    /// Create a new builder for this type
    pub fn builder() -> LargeImageBuilder<large_image_state::Empty, S> {
        LargeImageBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> LargeImageBuilder<St, S>
where
    St: large_image_state::State,
    St::Image: large_image_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> LargeImage<S> {
        LargeImage {
            image: 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>>,
    ) -> LargeImage<S> {
        LargeImage {
            image: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod small_blob_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;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Blob = 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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `blob` field
        pub struct blob(());
    }
}

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

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

impl<S: BosStr> SmallBlob<S> {
    /// Create a new builder for this type
    pub fn builder() -> SmallBlobBuilder<small_blob_state::Empty, S> {
        SmallBlobBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> SmallBlobBuilder<St, S>
where
    St: small_blob_state::State,
    St::Blob: small_blob_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SmallBlob<S> {
        SmallBlob {
            blob: 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>>,
    ) -> SmallBlob<S> {
        SmallBlob {
            blob: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod small_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 Image;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Image = Unset;
    }
    ///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 Image = Set<members::image>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `image` field
        pub struct image(());
    }
}

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

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

impl<S: BosStr> SmallImage<S> {
    /// Create a new builder for this type
    pub fn builder() -> SmallImageBuilder<small_image_state::Empty, S> {
        SmallImageBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> SmallImageBuilder<St, S>
where
    St: small_image_state::State,
    St::Image: small_image_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SmallImage<S> {
        SmallImage {
            image: 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>>,
    ) -> SmallImage<S> {
        SmallImage {
            image: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> SmallVideo<S> {
    /// Create a new builder for this type
    pub fn builder() -> SmallVideoBuilder<small_video_state::Empty, S> {
        SmallVideoBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> SmallVideoBuilder<St, S>
where
    St: small_video_state::State,
    St::Video: small_video_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SmallVideo<S> {
        SmallVideo {
            video: 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>>,
    ) -> SmallVideo<S> {
        SmallVideo {
            video: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod uri_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 UriBuilder<St: uri_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<UriValue<S>>,),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Uri<S> {
    /// Create a new builder for this type
    pub fn builder() -> UriBuilder<uri_state::Empty, S> {
        UriBuilder::builder()
    }
}

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

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

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

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