// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: tools.ozone.set.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. pub mod add_values; pub mod delete_set; pub mod delete_values; pub mod get_values; pub mod query_sets; pub mod upsert_set; #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct Set<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, #[serde(borrow)] pub name: jacquard_common::CowStr<'a>, } fn lexicon_doc_tools_ozone_set_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("tools.ozone.set.defs"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("set"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![::jacquard_common::smol_str::SmolStr::new_static("name")], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(10240usize), min_graphemes: None, max_graphemes: Some(1024usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: Some(3usize), max_length: Some(128usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("setView"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_common::smol_str::SmolStr::new_static("setSize"), ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), ::jacquard_common::smol_str::SmolStr::new_static("updatedAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "createdAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), 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( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(10240usize), min_graphemes: None, max_graphemes: Some(1024usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: Some(3usize), max_length: Some(128usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("setSize"), ::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( "updatedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Set<'a> { fn nsid() -> &'static str { "tools.ozone.set.defs" } fn def_name() -> &'static str { "set" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_tools_ozone_set_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10240usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 10240usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 1024usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 1024usize, actual: count, }); } } } { let value = &self.name; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 128usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 128usize, actual: ::len(value.as_ref()), }); } } { let value = &self.name; #[allow(unused_comparisons)] if ::len(value.as_ref()) < 3usize { return Err(::jacquard_lexicon::validation::ConstraintError::MinLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), min: 3usize, actual: ::len(value.as_ref()), }); } } Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct SetView<'a> { pub created_at: jacquard_common::types::string::Datetime, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, #[serde(borrow)] pub name: jacquard_common::CowStr<'a>, pub set_size: i64, pub updated_at: jacquard_common::types::string::Datetime, } pub mod set_view_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 CreatedAt; type Name; type UpdatedAt; type SetSize; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type CreatedAt = Unset; type Name = Unset; type UpdatedAt = Unset; type SetSize = Unset; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt(PhantomData S>); impl sealed::Sealed for SetCreatedAt {} impl State for SetCreatedAt { type CreatedAt = Set; type Name = S::Name; type UpdatedAt = S::UpdatedAt; type SetSize = S::SetSize; } ///State transition - sets the `name` field to Set pub struct SetName(PhantomData S>); impl sealed::Sealed for SetName {} impl State for SetName { type CreatedAt = S::CreatedAt; type Name = Set; type UpdatedAt = S::UpdatedAt; type SetSize = S::SetSize; } ///State transition - sets the `updated_at` field to Set pub struct SetUpdatedAt(PhantomData S>); impl sealed::Sealed for SetUpdatedAt {} impl State for SetUpdatedAt { type CreatedAt = S::CreatedAt; type Name = S::Name; type UpdatedAt = Set; type SetSize = S::SetSize; } ///State transition - sets the `set_size` field to Set pub struct SetSetSize(PhantomData S>); impl sealed::Sealed for SetSetSize {} impl State for SetSetSize { type CreatedAt = S::CreatedAt; type Name = S::Name; type UpdatedAt = S::UpdatedAt; type SetSize = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `created_at` field pub struct created_at(()); ///Marker type for the `name` field pub struct name(()); ///Marker type for the `updated_at` field pub struct updated_at(()); ///Marker type for the `set_size` field pub struct set_size(()); } } /// Builder for constructing an instance of this type pub struct SetViewBuilder<'a, S: set_view_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> SetView<'a> { /// Create a new builder for this type pub fn new() -> SetViewBuilder<'a, set_view_state::Empty> { SetViewBuilder::new() } } impl<'a> SetViewBuilder<'a, set_view_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { SetViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SetViewBuilder<'a, S> where S: set_view_state::State, S::CreatedAt: set_view_state::IsUnset, { /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into, ) -> SetViewBuilder<'a, set_view_state::SetCreatedAt> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); SetViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: set_view_state::State> SetViewBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S> SetViewBuilder<'a, S> where S: set_view_state::State, S::Name: set_view_state::IsUnset, { /// Set the `name` field (required) pub fn name( mut self, value: impl Into>, ) -> SetViewBuilder<'a, set_view_state::SetName> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); SetViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SetViewBuilder<'a, S> where S: set_view_state::State, S::SetSize: set_view_state::IsUnset, { /// Set the `setSize` field (required) pub fn set_size( mut self, value: impl Into, ) -> SetViewBuilder<'a, set_view_state::SetSetSize> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); SetViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SetViewBuilder<'a, S> where S: set_view_state::State, S::UpdatedAt: set_view_state::IsUnset, { /// Set the `updatedAt` field (required) pub fn updated_at( mut self, value: impl Into, ) -> SetViewBuilder<'a, set_view_state::SetUpdatedAt> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); SetViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SetViewBuilder<'a, S> where S: set_view_state::State, S::CreatedAt: set_view_state::IsSet, S::Name: set_view_state::IsSet, S::UpdatedAt: set_view_state::IsSet, S::SetSize: set_view_state::IsSet, { /// Build the final struct pub fn build(self) -> SetView<'a> { SetView { created_at: self.__unsafe_private_named.0.unwrap(), description: self.__unsafe_private_named.1, name: self.__unsafe_private_named.2.unwrap(), set_size: self.__unsafe_private_named.3.unwrap(), updated_at: self.__unsafe_private_named.4.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>, >, ) -> SetView<'a> { SetView { created_at: self.__unsafe_private_named.0.unwrap(), description: self.__unsafe_private_named.1, name: self.__unsafe_private_named.2.unwrap(), set_size: self.__unsafe_private_named.3.unwrap(), updated_at: self.__unsafe_private_named.4.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SetView<'a> { fn nsid() -> &'static str { "tools.ozone.set.defs" } fn def_name() -> &'static str { "setView" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_tools_ozone_set_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10240usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 10240usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 1024usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 1024usize, actual: count, }); } } } { let value = &self.name; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 128usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 128usize, actual: ::len(value.as_ref()), }); } } { let value = &self.name; #[allow(unused_comparisons)] if ::len(value.as_ref()) < 3usize { return Err(::jacquard_lexicon::validation::ConstraintError::MinLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), min: 3usize, actual: ::len(value.as_ref()), }); } } Ok(()) } }