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::{BosStr, CowStr, 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::{Datetime, Did, Nsid};
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::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DefsOption<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<Datetime>,
pub created_by: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub did: Did<S>,
pub key: Nsid<S>,
pub last_updated_by: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manager_role: Option<DefsOptionManagerRole<S>>,
pub scope: DefsOptionScope<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<Datetime>,
pub value: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DefsOptionManagerRole<S: BosStr = DefaultStr> {
RoleModerator,
RoleTriage,
RoleAdmin,
RoleVerifier,
Other(S),
}
impl<S: BosStr> DefsOptionManagerRole<S> {
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(),
}
}
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<S: BosStr> core::fmt::Display for DefsOptionManagerRole<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for DefsOptionManagerRole<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for DefsOptionManagerRole<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for DefsOptionManagerRole<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for DefsOptionManagerRole<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for DefsOptionManagerRole<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = DefsOptionManagerRole<S::Output>;
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<S: BosStr = DefaultStr> {
Instance,
Personal,
Other(S),
}
impl<S: BosStr> DefsOptionScope<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Instance => "instance",
Self::Personal => "personal",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"instance" => Self::Instance,
"personal" => Self::Personal,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for DefsOptionScope<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for DefsOptionScope<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for DefsOptionScope<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for DefsOptionScope<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for DefsOptionScope<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for DefsOptionScope<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = DefsOptionScope<S::Output>;
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<S: BosStr> LexiconSchema for DefsOption<S> {
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 <str>::len(value.as_ref()) > 10240usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 10240usize,
actual: <str>::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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Key;
type Value;
type Did;
type Scope;
type LastUpdatedBy;
type CreatedBy;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Key = Unset;
type Value = Unset;
type Did = Unset;
type Scope = Unset;
type LastUpdatedBy = Unset;
type CreatedBy = Unset;
}
pub struct SetKey<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetKey<St> {}
impl<St: State> State for SetKey<St> {
type Key = Set<members::key>;
type Value = St::Value;
type Did = St::Did;
type Scope = St::Scope;
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedBy = St::CreatedBy;
}
pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValue<St> {}
impl<St: State> State for SetValue<St> {
type Key = St::Key;
type Value = Set<members::value>;
type Did = St::Did;
type Scope = St::Scope;
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedBy = St::CreatedBy;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Key = St::Key;
type Value = St::Value;
type Did = Set<members::did>;
type Scope = St::Scope;
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedBy = St::CreatedBy;
}
pub struct SetScope<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetScope<St> {}
impl<St: State> State for SetScope<St> {
type Key = St::Key;
type Value = St::Value;
type Did = St::Did;
type Scope = Set<members::scope>;
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedBy = St::CreatedBy;
}
pub struct SetLastUpdatedBy<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLastUpdatedBy<St> {}
impl<St: State> State for SetLastUpdatedBy<St> {
type Key = St::Key;
type Value = St::Value;
type Did = St::Did;
type Scope = St::Scope;
type LastUpdatedBy = Set<members::last_updated_by>;
type CreatedBy = St::CreatedBy;
}
pub struct SetCreatedBy<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedBy<St> {}
impl<St: State> State for SetCreatedBy<St> {
type Key = St::Key;
type Value = St::Value;
type Did = St::Did;
type Scope = St::Scope;
type LastUpdatedBy = St::LastUpdatedBy;
type CreatedBy = Set<members::created_by>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct key(());
pub struct value(());
pub struct did(());
pub struct scope(());
pub struct last_updated_by(());
pub struct created_by(());
}
}
pub struct DefsOptionBuilder<S: BosStr, St: defs_option_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<Did<S>>,
Option<S>,
Option<Did<S>>,
Option<Nsid<S>>,
Option<Did<S>>,
Option<DefsOptionManagerRole<S>>,
Option<DefsOptionScope<S>>,
Option<Datetime>,
Option<Data<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DefsOption<S> {
pub fn new() -> DefsOptionBuilder<S, defs_option_state::Empty> {
DefsOptionBuilder::new()
}
}
impl<S: BosStr> DefsOptionBuilder<S, defs_option_state::Empty> {
pub fn new() -> Self {
DefsOptionBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: defs_option_state::State> DefsOptionBuilder<S, St> {
pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::CreatedBy: defs_option_state::IsUnset,
{
pub fn created_by(
mut self,
value: impl Into<Did<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetCreatedBy<St>> {
self._fields.1 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: defs_option_state::State> DefsOptionBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::Did: defs_option_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetDid<St>> {
self._fields.3 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::Key: defs_option_state::IsUnset,
{
pub fn key(
mut self,
value: impl Into<Nsid<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetKey<St>> {
self._fields.4 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::LastUpdatedBy: defs_option_state::IsUnset,
{
pub fn last_updated_by(
mut self,
value: impl Into<Did<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetLastUpdatedBy<St>> {
self._fields.5 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: defs_option_state::State> DefsOptionBuilder<S, St> {
pub fn manager_role(mut self, value: impl Into<Option<DefsOptionManagerRole<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_manager_role(mut self, value: Option<DefsOptionManagerRole<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::Scope: defs_option_state::IsUnset,
{
pub fn scope(
mut self,
value: impl Into<DefsOptionScope<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetScope<St>> {
self._fields.7 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: defs_option_state::State> DefsOptionBuilder<S, St> {
pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::Value: defs_option_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<Data<S>>,
) -> DefsOptionBuilder<S, defs_option_state::SetValue<St>> {
self._fields.9 = Option::Some(value.into());
DefsOptionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DefsOptionBuilder<S, St>
where
St: defs_option_state::State,
St::Key: defs_option_state::IsSet,
St::Value: defs_option_state::IsSet,
St::Did: defs_option_state::IsSet,
St::Scope: defs_option_state::IsSet,
St::LastUpdatedBy: defs_option_state::IsSet,
St::CreatedBy: defs_option_state::IsSet,
{
pub fn build(self) -> DefsOption<S> {
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(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DefsOption<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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()
}
}