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

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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::string::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};
/// Object containing a blob to external data

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LargeBlob<'a> {
    ///Blob to external data (up to 100MB)
    #[serde(borrow)]
    pub blob: BlobRef<'a>,
}

/// Object containing a large image

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LargeImage<'a> {
    ///Image (up to 10MB)
    #[serde(borrow)]
    pub image: BlobRef<'a>,
}

/// Object containing a blob to external data

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallBlob<'a> {
    ///Blob to external data (up to 10MB)
    #[serde(borrow)]
    pub blob: BlobRef<'a>,
}

/// Object containing a small image

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallImage<'a> {
    ///Image (up to 5MB)
    #[serde(borrow)]
    pub image: BlobRef<'a>,
}

/// Object containing a small video

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SmallVideo<'a> {
    ///Video (up to 20MB)
    #[serde(borrow)]
    pub video: BlobRef<'a>,
}

/// Object containing a URI to external data

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Uri<'a> {
    ///URI to external data
    #[serde(borrow)]
    pub uri: UriValue<'a>,
}

impl<'a> LexiconSchema for LargeBlob<'a> {
    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<'a> LexiconSchema for LargeImage<'a> {
    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<'a> LexiconSchema for SmallBlob<'a> {
    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<'a> LexiconSchema for SmallImage<'a> {
    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<'a> LexiconSchema for SmallVideo<'a> {
    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<'a> LexiconSchema for Uri<'a> {
    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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBlob<S> {}
    impl<S: State> State for SetBlob<S> {
        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<'a, S: large_blob_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> LargeBlobBuilder<'a, S>
where
    S: large_blob_state::State,
    S::Blob: large_blob_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LargeBlob<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LargeBlob<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetImage<S> {}
    impl<S: State> State for SetImage<S> {
        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<'a, S: large_image_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> LargeImageBuilder<'a, S>
where
    S: large_image_state::State,
    S::Image: large_image_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> LargeImage<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> LargeImage<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBlob<S> {}
    impl<S: State> State for SetBlob<S> {
        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<'a, S: small_blob_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> SmallBlobBuilder<'a, S>
where
    S: small_blob_state::State,
    S::Blob: small_blob_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SmallBlob<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SmallBlob<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetImage<S> {}
    impl<S: State> State for SetImage<S> {
        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<'a, S: small_image_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> SmallImageBuilder<'a, S>
where
    S: small_image_state::State,
    S::Image: small_image_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SmallImage<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SmallImage<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetVideo<S> {}
    impl<S: State> State for SetVideo<S> {
        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<'a, S: small_video_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S> SmallVideoBuilder<'a, S>
where
    S: small_video_state::State,
    S::Video: small_video_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SmallVideo<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SmallVideo<'a> {
        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<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        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<'a, S: uri_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<UriValue<'a>>,),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

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