// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: pub.leaflet.blocks.image // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct AspectRatio<'a> { pub height: i64, pub width: i64, } pub mod aspect_ratio_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Width; type Height; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Width = Unset; type Height = Unset; } ///State transition - sets the `width` field to Set pub struct SetWidth(PhantomData S>); impl sealed::Sealed for SetWidth {} impl State for SetWidth { type Width = Set; type Height = S::Height; } ///State transition - sets the `height` field to Set pub struct SetHeight(PhantomData S>); impl sealed::Sealed for SetHeight {} impl State for SetHeight { type Width = S::Width; type Height = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `width` field pub struct width(()); ///Marker type for the `height` field pub struct height(()); } } /// Builder for constructing an instance of this type pub struct AspectRatioBuilder<'a, S: aspect_ratio_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: (::core::option::Option, ::core::option::Option), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> AspectRatio<'a> { /// Create a new builder for this type pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> { AspectRatioBuilder::new() } } impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { AspectRatioBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> AspectRatioBuilder<'a, S> where S: aspect_ratio_state::State, S::Height: aspect_ratio_state::IsUnset, { /// Set the `height` field (required) pub fn height( mut self, value: impl Into, ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); AspectRatioBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> AspectRatioBuilder<'a, S> where S: aspect_ratio_state::State, S::Width: aspect_ratio_state::IsUnset, { /// Set the `width` field (required) pub fn width( mut self, value: impl Into, ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); AspectRatioBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> AspectRatioBuilder<'a, S> where S: aspect_ratio_state::State, S::Width: aspect_ratio_state::IsSet, S::Height: aspect_ratio_state::IsSet, { /// Build the final struct pub fn build(self) -> AspectRatio<'a> { AspectRatio { height: self.__unsafe_private_named.0.unwrap(), width: self.__unsafe_private_named.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> AspectRatio<'a> { AspectRatio { height: self.__unsafe_private_named.0.unwrap(), width: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_pub_leaflet_blocks_image() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.image"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("aspectRatio"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("width"), ::jacquard_common::smol_str::SmolStr::new_static("height") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("height"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("width"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("image"), ::jacquard_common::smol_str::SmolStr::new_static("aspectRatio") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("alt"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Alt text description of the image, for accessibility.", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "aspectRatio", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#aspectRatio"), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("image"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AspectRatio<'a> { fn nsid() -> &'static str { "pub.leaflet.blocks.image" } fn def_name() -> &'static str { "aspectRatio" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_pub_leaflet_blocks_image() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Image<'a> { /// Alt text description of the image, for accessibility. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub alt: std::option::Option>, #[serde(borrow)] pub aspect_ratio: crate::pub_leaflet::blocks::image::AspectRatio<'a>, #[serde(borrow)] pub image: jacquard_common::types::blob::BlobRef<'a>, } pub mod image_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Image; type AspectRatio; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Image = Unset; type AspectRatio = Unset; } ///State transition - sets the `image` field to Set pub struct SetImage(PhantomData S>); impl sealed::Sealed for SetImage {} impl State for SetImage { type Image = Set; type AspectRatio = S::AspectRatio; } ///State transition - sets the `aspect_ratio` field to Set pub struct SetAspectRatio(PhantomData S>); impl sealed::Sealed for SetAspectRatio {} impl State for SetAspectRatio { type Image = S::Image; type AspectRatio = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `image` field pub struct image(()); ///Marker type for the `aspect_ratio` field pub struct aspect_ratio(()); } } /// Builder for constructing an instance of this type pub struct ImageBuilder<'a, S: image_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Image<'a> { /// Create a new builder for this type pub fn new() -> ImageBuilder<'a, image_state::Empty> { ImageBuilder::new() } } impl<'a> ImageBuilder<'a, image_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ImageBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: image_state::State> ImageBuilder<'a, S> { /// Set the `alt` field (optional) pub fn alt(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `alt` field to an Option value (optional) pub fn maybe_alt(mut self, value: Option>) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S> ImageBuilder<'a, S> where S: image_state::State, S::AspectRatio: image_state::IsUnset, { /// Set the `aspectRatio` field (required) pub fn aspect_ratio( mut self, value: impl Into>, ) -> ImageBuilder<'a, image_state::SetAspectRatio> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); ImageBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ImageBuilder<'a, S> where S: image_state::State, S::Image: image_state::IsUnset, { /// Set the `image` field (required) pub fn image( mut self, value: impl Into>, ) -> ImageBuilder<'a, image_state::SetImage> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); ImageBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ImageBuilder<'a, S> where S: image_state::State, S::Image: image_state::IsSet, S::AspectRatio: image_state::IsSet, { /// Build the final struct pub fn build(self) -> Image<'a> { Image { alt: self.__unsafe_private_named.0, aspect_ratio: self.__unsafe_private_named.1.unwrap(), image: self.__unsafe_private_named.2.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Image<'a> { Image { alt: self.__unsafe_private_named.0, aspect_ratio: self.__unsafe_private_named.1.unwrap(), image: self.__unsafe_private_named.2.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Image<'a> { fn nsid() -> &'static str { "pub.leaflet.blocks.image" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_pub_leaflet_blocks_image() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }