// @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. //! Generated bindings for the `tools.ozone.setting` Lexicon namespace/module. pub mod list_options; pub mod remove_options; pub mod upsert_option; #[allow(unused_imports)] use alloc::collections::BTreeMap; #[allow(unused_imports)] use core::marker::PhantomData; use jacquard_common::{CowStr, 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::string::{Did, Nsid, Datetime}; 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}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub struct DefsOption { #[serde(skip_serializing_if = "Option::is_none")] pub created_at: Option, pub created_by: Did, #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, pub did: Did, pub key: Nsid, pub last_updated_by: Did, #[serde(skip_serializing_if = "Option::is_none")] pub manager_role: Option>, pub scope: DefsOptionScope, #[serde(skip_serializing_if = "Option::is_none")] pub updated_at: Option, pub value: Data, #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Option>>, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DefsOptionManagerRole { RoleModerator, RoleTriage, RoleAdmin, RoleVerifier, Other(S), } impl DefsOptionManagerRole { 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(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "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(s), } } } impl core::fmt::Display for DefsOptionManagerRole { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for DefsOptionManagerRole { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for DefsOptionManagerRole { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for DefsOptionManagerRole { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for DefsOptionManagerRole { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for DefsOptionManagerRole where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = DefsOptionManagerRole; 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 { Instance, Personal, Other(S), } impl DefsOptionScope { pub fn as_str(&self) -> &str { match self { Self::Instance => "instance", Self::Personal => "personal", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "instance" => Self::Instance, "personal" => Self::Personal, _ => Self::Other(s), } } } impl core::fmt::Display for DefsOptionScope { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for DefsOptionScope { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for DefsOptionScope { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for DefsOptionScope { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for DefsOptionScope { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for DefsOptionScope where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = DefsOptionScope; fn into_static(self) -> Self::Output { match self { DefsOptionScope::Instance => DefsOptionScope::Instance, DefsOptionScope::Personal => DefsOptionScope::Personal, DefsOptionScope::Other(v) => DefsOptionScope::Other(v.into_static()), } } } impl LexiconSchema for DefsOption { fn nsid() -> &'static str { "tools.ozone.setting.defs" } fn def_name() -> &'static str { "option" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_tools_ozone_setting_defs() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10240usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("description"), max: 10240usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 1024usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("description"), max: 1024usize, actual: count, }); } } } Ok(()) } } 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 Did; type Key; type LastUpdatedBy; type Scope; type Value; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type CreatedBy = Unset; type Did = Unset; type Key = Unset; type LastUpdatedBy = Unset; type Scope = Unset; type Value = Unset; } ///State transition - sets the `created_by` field to Set pub struct SetCreatedBy(PhantomData St>); impl sealed::Sealed for SetCreatedBy {} impl State for SetCreatedBy { type CreatedBy = Set; type Did = St::Did; type Key = St::Key; type LastUpdatedBy = St::LastUpdatedBy; type Scope = St::Scope; type Value = St::Value; } ///State transition - sets the `did` field to Set pub struct SetDid(PhantomData St>); impl sealed::Sealed for SetDid {} impl State for SetDid { type CreatedBy = St::CreatedBy; type Did = Set; type Key = St::Key; type LastUpdatedBy = St::LastUpdatedBy; type Scope = St::Scope; type Value = St::Value; } ///State transition - sets the `key` field to Set pub struct SetKey(PhantomData St>); impl sealed::Sealed for SetKey {} impl State for SetKey { type CreatedBy = St::CreatedBy; type Did = St::Did; type Key = Set; type LastUpdatedBy = St::LastUpdatedBy; type Scope = St::Scope; type Value = St::Value; } ///State transition - sets the `last_updated_by` field to Set pub struct SetLastUpdatedBy(PhantomData St>); impl sealed::Sealed for SetLastUpdatedBy {} impl State for SetLastUpdatedBy { type CreatedBy = St::CreatedBy; type Did = St::Did; type Key = St::Key; type LastUpdatedBy = Set; type Scope = St::Scope; type Value = St::Value; } ///State transition - sets the `scope` field to Set pub struct SetScope(PhantomData St>); impl sealed::Sealed for SetScope {} impl State for SetScope { type CreatedBy = St::CreatedBy; type Did = St::Did; type Key = St::Key; type LastUpdatedBy = St::LastUpdatedBy; type Scope = Set; type Value = St::Value; } ///State transition - sets the `value` field to Set pub struct SetValue(PhantomData St>); impl sealed::Sealed for SetValue {} impl State for SetValue { type CreatedBy = St::CreatedBy; type Did = St::Did; type Key = St::Key; type LastUpdatedBy = St::LastUpdatedBy; type Scope = St::Scope; type Value = 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 `did` field pub struct did(()); ///Marker type for the `key` field pub struct key(()); ///Marker type for the `last_updated_by` field pub struct last_updated_by(()); ///Marker type for the `scope` field pub struct scope(()); ///Marker type for the `value` field pub struct value(()); } } /// Builder for constructing an instance of this type. pub struct DefsOptionBuilder { _state: PhantomData St>, _fields: ( Option, Option>, Option, Option>, Option>, Option>, Option>, Option>, Option, Option>, ), _type: PhantomData S>, } impl DefsOption { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> DefsOptionBuilder { DefsOptionBuilder::new() } } impl DefsOption { /// Create a new builder for this type pub fn builder() -> DefsOptionBuilder { DefsOptionBuilder::builder() } } impl DefsOptionBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { DefsOptionBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl DefsOptionBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { DefsOptionBuilder { _state: PhantomData, _fields: (None, None, None, None, None, None, None, None, None, None), _type: PhantomData, } } } impl DefsOptionBuilder { /// Set the `createdAt` field (optional) pub fn created_at(mut self, value: impl Into>) -> Self { self._fields.0 = value.into(); self } /// Set the `createdAt` field to an Option value (optional) pub fn maybe_created_at(mut self, value: Option) -> Self { self._fields.0 = value; self } } impl DefsOptionBuilder where St: defs_option_state::State, St::CreatedBy: defs_option_state::IsUnset, { /// Set the `createdBy` field (required) pub fn created_by( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.1 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder { /// Set the `description` field (optional) pub fn description(mut self, value: impl Into>) -> Self { self._fields.2 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description(mut self, value: Option) -> Self { self._fields.2 = value; self } } impl DefsOptionBuilder where St: defs_option_state::State, St::Did: defs_option_state::IsUnset, { /// Set the `did` field (required) pub fn did( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.3 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder where St: defs_option_state::State, St::Key: defs_option_state::IsUnset, { /// Set the `key` field (required) pub fn key( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.4 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder where St: defs_option_state::State, St::LastUpdatedBy: defs_option_state::IsUnset, { /// Set the `lastUpdatedBy` field (required) pub fn last_updated_by( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.5 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder { /// Set the `managerRole` field (optional) pub fn manager_role( mut self, value: impl Into>>, ) -> Self { self._fields.6 = value.into(); self } /// Set the `managerRole` field to an Option value (optional) pub fn maybe_manager_role( mut self, value: Option>, ) -> Self { self._fields.6 = value; self } } impl DefsOptionBuilder where St: defs_option_state::State, St::Scope: defs_option_state::IsUnset, { /// Set the `scope` field (required) pub fn scope( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.7 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder { /// Set the `updatedAt` field (optional) pub fn updated_at(mut self, value: impl Into>) -> Self { self._fields.8 = value.into(); self } /// Set the `updatedAt` field to an Option value (optional) pub fn maybe_updated_at(mut self, value: Option) -> Self { self._fields.8 = value; self } } impl DefsOptionBuilder where St: defs_option_state::State, St::Value: defs_option_state::IsUnset, { /// Set the `value` field (required) pub fn value( mut self, value: impl Into>, ) -> DefsOptionBuilder, S> { self._fields.9 = Option::Some(value.into()); DefsOptionBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DefsOptionBuilder where St: defs_option_state::State, St::CreatedBy: defs_option_state::IsSet, St::Did: defs_option_state::IsSet, St::Key: defs_option_state::IsSet, St::LastUpdatedBy: defs_option_state::IsSet, St::Scope: defs_option_state::IsSet, St::Value: defs_option_state::IsSet, { /// Build the final struct. pub fn build(self) -> DefsOption { DefsOption { created_at: self._fields.0, created_by: self._fields.1.unwrap(), description: self._fields.2, did: self._fields.3.unwrap(), key: self._fields.4.unwrap(), last_updated_by: self._fields.5.unwrap(), manager_role: self._fields.6, scope: self._fields.7.unwrap(), updated_at: self._fields.8, value: self._fields.9.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data( self, extra_data: BTreeMap>, ) -> DefsOption { DefsOption { created_at: self._fields.0, created_by: self._fields.1.unwrap(), description: self._fields.2, did: self._fields.3.unwrap(), key: self._fields.4.unwrap(), last_updated_by: self._fields.5.unwrap(), manager_role: self._fields.6, scope: self._fields.7.unwrap(), updated_at: self._fields.8, value: self._fields.9.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_tools_ozone_setting_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("tools.ozone.setting.defs"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("option"), LexUserType::Object(LexObject { required: Some( vec![ SmolStr::new_static("key"), SmolStr::new_static("value"), SmolStr::new_static("did"), SmolStr::new_static("scope"), SmolStr::new_static("createdBy"), SmolStr::new_static("lastUpdatedBy") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("createdAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("createdBy"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("description"), LexObjectProperty::String(LexString { max_length: Some(10240usize), max_graphemes: Some(1024usize), ..Default::default() }), ); map.insert( SmolStr::new_static("did"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("key"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Nsid), ..Default::default() }), ); map.insert( SmolStr::new_static("lastUpdatedBy"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("managerRole"), LexObjectProperty::String(LexString { ..Default::default() }), ); map.insert( SmolStr::new_static("scope"), LexObjectProperty::String(LexString { ..Default::default() }), ); map.insert( SmolStr::new_static("updatedAt"), LexObjectProperty::String(LexString { format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("value"), LexObjectProperty::Unknown(LexUnknown { ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } }