// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: tools.ozone.setting.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. pub mod list_options; pub mod remove_options; pub mod upsert_option; #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct DefsOption<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] pub created_at: std::option::Option, #[serde(borrow)] pub created_by: jacquard_common::types::string::Did<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, #[serde(borrow)] pub did: jacquard_common::types::string::Did<'a>, #[serde(borrow)] pub key: jacquard_common::types::string::Nsid<'a>, #[serde(borrow)] pub last_updated_by: jacquard_common::types::string::Did<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub manager_role: std::option::Option>, #[serde(borrow)] pub scope: DefsOptionScope<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub updated_at: std::option::Option, #[serde(borrow)] pub value: jacquard_common::types::value::Data<'a>, } pub mod defs_option_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 CreatedBy; type Scope; type Key; type Value; type Did; type LastUpdatedBy; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type CreatedBy = Unset; type Scope = Unset; type Key = Unset; type Value = Unset; type Did = Unset; type LastUpdatedBy = Unset; } ///State transition - sets the `created_by` field to Set pub struct SetCreatedBy(PhantomData S>); impl sealed::Sealed for SetCreatedBy {} impl State for SetCreatedBy { type CreatedBy = Set; type Scope = S::Scope; type Key = S::Key; type Value = S::Value; type Did = S::Did; type LastUpdatedBy = S::LastUpdatedBy; } ///State transition - sets the `scope` field to Set pub struct SetScope(PhantomData S>); impl sealed::Sealed for SetScope {} impl State for SetScope { type CreatedBy = S::CreatedBy; type Scope = Set; type Key = S::Key; type Value = S::Value; type Did = S::Did; type LastUpdatedBy = S::LastUpdatedBy; } ///State transition - sets the `key` field to Set pub struct SetKey(PhantomData S>); impl sealed::Sealed for SetKey {} impl State for SetKey { type CreatedBy = S::CreatedBy; type Scope = S::Scope; type Key = Set; type Value = S::Value; type Did = S::Did; type LastUpdatedBy = S::LastUpdatedBy; } ///State transition - sets the `value` field to Set pub struct SetValue(PhantomData S>); impl sealed::Sealed for SetValue {} impl State for SetValue { type CreatedBy = S::CreatedBy; type Scope = S::Scope; type Key = S::Key; type Value = Set; type Did = S::Did; type LastUpdatedBy = S::LastUpdatedBy; } ///State transition - sets the `did` field to Set pub struct SetDid(PhantomData S>); impl sealed::Sealed for SetDid {} impl State for SetDid { type CreatedBy = S::CreatedBy; type Scope = S::Scope; type Key = S::Key; type Value = S::Value; type Did = Set; type LastUpdatedBy = S::LastUpdatedBy; } ///State transition - sets the `last_updated_by` field to Set pub struct SetLastUpdatedBy(PhantomData S>); impl sealed::Sealed for SetLastUpdatedBy {} impl State for SetLastUpdatedBy { type CreatedBy = S::CreatedBy; type Scope = S::Scope; type Key = S::Key; type Value = S::Value; type Did = S::Did; type LastUpdatedBy = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `created_by` field pub struct created_by(()); ///Marker type for the `scope` field pub struct scope(()); ///Marker type for the `key` field pub struct key(()); ///Marker type for the `value` field pub struct value(()); ///Marker type for the `did` field pub struct did(()); ///Marker type for the `last_updated_by` field pub struct last_updated_by(()); } } /// Builder for constructing an instance of this type pub struct DefsOptionBuilder<'a, S: defs_option_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>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> DefsOption<'a> { /// Create a new builder for this type pub fn new() -> DefsOptionBuilder<'a, defs_option_state::Empty> { DefsOptionBuilder::new() } } impl<'a> DefsOptionBuilder<'a, defs_option_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: ( None, None, None, None, None, None, None, None, None, None, ), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: defs_option_state::State> DefsOptionBuilder<'a, S> { /// Set the `createdAt` field (optional) pub fn created_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `createdAt` field to an Option value (optional) pub fn maybe_created_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::CreatedBy: defs_option_state::IsUnset, { /// Set the `createdBy` field (required) pub fn created_by( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetCreatedBy> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: defs_option_state::State> DefsOptionBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = 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.2 = value; self } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::Did: defs_option_state::IsUnset, { /// Set the `did` field (required) pub fn did( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetDid> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::Key: defs_option_state::IsUnset, { /// Set the `key` field (required) pub fn key( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetKey> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::LastUpdatedBy: defs_option_state::IsUnset, { /// Set the `lastUpdatedBy` field (required) pub fn last_updated_by( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetLastUpdatedBy> { self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: defs_option_state::State> DefsOptionBuilder<'a, S> { /// Set the `managerRole` field (optional) pub fn manager_role( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `managerRole` field to an Option value (optional) pub fn maybe_manager_role( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::Scope: defs_option_state::IsUnset, { /// Set the `scope` field (required) pub fn scope( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetScope> { self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: defs_option_state::State> DefsOptionBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.8 = value.into(); self } /// Set the `updatedAt` field to an Option value (optional) pub fn maybe_updated_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.8 = value; self } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::Value: defs_option_state::IsUnset, { /// Set the `value` field (required) pub fn value( mut self, value: impl Into>, ) -> DefsOptionBuilder<'a, defs_option_state::SetValue> { self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into()); DefsOptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> DefsOptionBuilder<'a, S> where S: defs_option_state::State, S::CreatedBy: defs_option_state::IsSet, S::Scope: defs_option_state::IsSet, S::Key: defs_option_state::IsSet, S::Value: defs_option_state::IsSet, S::Did: defs_option_state::IsSet, S::LastUpdatedBy: defs_option_state::IsSet, { /// Build the final struct pub fn build(self) -> DefsOption<'a> { DefsOption { created_at: self.__unsafe_private_named.0, created_by: self.__unsafe_private_named.1.unwrap(), description: self.__unsafe_private_named.2, did: self.__unsafe_private_named.3.unwrap(), key: self.__unsafe_private_named.4.unwrap(), last_updated_by: self.__unsafe_private_named.5.unwrap(), manager_role: self.__unsafe_private_named.6, scope: self.__unsafe_private_named.7.unwrap(), updated_at: self.__unsafe_private_named.8, value: self.__unsafe_private_named.9.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>, >, ) -> DefsOption<'a> { DefsOption { created_at: self.__unsafe_private_named.0, created_by: self.__unsafe_private_named.1.unwrap(), description: self.__unsafe_private_named.2, did: self.__unsafe_private_named.3.unwrap(), key: self.__unsafe_private_named.4.unwrap(), last_updated_by: self.__unsafe_private_named.5.unwrap(), manager_role: self.__unsafe_private_named.6, scope: self.__unsafe_private_named.7.unwrap(), updated_at: self.__unsafe_private_named.8, value: self.__unsafe_private_named.9.unwrap(), extra_data: Some(extra_data), } } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DefsOptionManagerRole<'a> { RoleModerator, RoleTriage, RoleAdmin, RoleVerifier, Other(jacquard_common::CowStr<'a>), } impl<'a> DefsOptionManagerRole<'a> { pub fn as_str(&self) -> &str { match self { Self::RoleModerator => "tools.ozone.team.defs#roleModerator", Self::RoleTriage => "tools.ozone.team.defs#roleTriage", Self::RoleAdmin => "tools.ozone.team.defs#roleAdmin", Self::RoleVerifier => "tools.ozone.team.defs#roleVerifier", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for DefsOptionManagerRole<'a> { fn from(s: &'a str) -> Self { match s { "tools.ozone.team.defs#roleModerator" => Self::RoleModerator, "tools.ozone.team.defs#roleTriage" => Self::RoleTriage, "tools.ozone.team.defs#roleAdmin" => Self::RoleAdmin, "tools.ozone.team.defs#roleVerifier" => Self::RoleVerifier, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for DefsOptionManagerRole<'a> { fn from(s: String) -> Self { match s.as_str() { "tools.ozone.team.defs#roleModerator" => Self::RoleModerator, "tools.ozone.team.defs#roleTriage" => Self::RoleTriage, "tools.ozone.team.defs#roleAdmin" => Self::RoleAdmin, "tools.ozone.team.defs#roleVerifier" => Self::RoleVerifier, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for DefsOptionManagerRole<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for DefsOptionManagerRole<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for DefsOptionManagerRole<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for DefsOptionManagerRole<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for DefsOptionManagerRole<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for DefsOptionManagerRole<'_> { type Output = DefsOptionManagerRole<'static>; fn into_static(self) -> Self::Output { match self { DefsOptionManagerRole::RoleModerator => DefsOptionManagerRole::RoleModerator, DefsOptionManagerRole::RoleTriage => DefsOptionManagerRole::RoleTriage, DefsOptionManagerRole::RoleAdmin => DefsOptionManagerRole::RoleAdmin, DefsOptionManagerRole::RoleVerifier => DefsOptionManagerRole::RoleVerifier, DefsOptionManagerRole::Other(v) => { DefsOptionManagerRole::Other(v.into_static()) } } } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DefsOptionScope<'a> { Instance, Personal, Other(jacquard_common::CowStr<'a>), } impl<'a> DefsOptionScope<'a> { pub fn as_str(&self) -> &str { match self { Self::Instance => "instance", Self::Personal => "personal", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for DefsOptionScope<'a> { fn from(s: &'a str) -> Self { match s { "instance" => Self::Instance, "personal" => Self::Personal, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for DefsOptionScope<'a> { fn from(s: String) -> Self { match s.as_str() { "instance" => Self::Instance, "personal" => Self::Personal, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for DefsOptionScope<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for DefsOptionScope<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for DefsOptionScope<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for DefsOptionScope<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for DefsOptionScope<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for DefsOptionScope<'_> { type Output = DefsOptionScope<'static>; fn into_static(self) -> Self::Output { match self { DefsOptionScope::Instance => DefsOptionScope::Instance, DefsOptionScope::Personal => DefsOptionScope::Personal, DefsOptionScope::Other(v) => DefsOptionScope::Other(v.into_static()), } } } fn lexicon_doc_tools_ozone_setting_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("tools.ozone.setting.defs"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("option"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("key"), ::jacquard_common::smol_str::SmolStr::new_static("value"), ::jacquard_common::smol_str::SmolStr::new_static("did"), ::jacquard_common::smol_str::SmolStr::new_static("scope"), ::jacquard_common::smol_str::SmolStr::new_static("createdBy"), ::jacquard_common::smol_str::SmolStr::new_static("lastUpdatedBy") ], ), 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( "createdBy", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Did, ), 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("did"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Did, ), 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("key"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Nsid, ), 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( "lastUpdatedBy", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Did, ), 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( "managerRole", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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("scope"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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( "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.insert( ::jacquard_common::smol_str::SmolStr::new_static("value"), ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown { description: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for DefsOption<'a> { fn nsid() -> &'static str { "tools.ozone.setting.defs" } fn def_name() -> &'static str { "option" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_tools_ozone_setting_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, }); } } } Ok(()) } }