pub mod add_values;
pub mod delete_set;
pub mod delete_values;
pub mod get_values;
pub mod query_sets;
pub mod upsert_set;
#[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::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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Set<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SetView<S: BosStr = DefaultStr> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub name: S,
pub set_size: i64,
pub updated_at: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Set<S> {
fn nsid() -> &'static str {
"tools.ozone.set.defs"
}
fn def_name() -> &'static str {
"set"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_set_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,
});
}
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 3usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("name"),
min: 3usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SetView<S> {
fn nsid() -> &'static str {
"tools.ozone.set.defs"
}
fn def_name() -> &'static str {
"setView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_tools_ozone_set_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,
});
}
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 3usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("name"),
min: 3usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_tools_ozone_set_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.set.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("set"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
max_length: Some(10240usize),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
min_length: Some(3usize),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("setView"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("setSize"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("updatedAt")
],
),
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("description"),
LexObjectProperty::String(LexString {
max_length: Some(10240usize),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
min_length: Some(3usize),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("setSize"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
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 {}
}
pub trait State: sealed::Sealed {
type CreatedAt;
type SetSize;
type UpdatedAt;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type SetSize = Unset;
type UpdatedAt = Unset;
type Name = Unset;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type CreatedAt = Set<members::created_at>;
type SetSize = St::SetSize;
type UpdatedAt = St::UpdatedAt;
type Name = St::Name;
}
pub struct SetSetSize<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSetSize<St> {}
impl<St: State> State for SetSetSize<St> {
type CreatedAt = St::CreatedAt;
type SetSize = Set<members::set_size>;
type UpdatedAt = St::UpdatedAt;
type Name = St::Name;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type CreatedAt = St::CreatedAt;
type SetSize = St::SetSize;
type UpdatedAt = Set<members::updated_at>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type CreatedAt = St::CreatedAt;
type SetSize = St::SetSize;
type UpdatedAt = St::UpdatedAt;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct set_size(());
pub struct updated_at(());
pub struct name(());
}
}
pub struct SetViewBuilder<S: BosStr, St: set_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<S>, Option<S>, Option<i64>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SetView<S> {
pub fn new() -> SetViewBuilder<S, set_view_state::Empty> {
SetViewBuilder::new()
}
}
impl<S: BosStr> SetViewBuilder<S, set_view_state::Empty> {
pub fn new() -> Self {
SetViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SetViewBuilder<S, St>
where
St: set_view_state::State,
St::CreatedAt: set_view_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> SetViewBuilder<S, set_view_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
SetViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: set_view_state::State> SetViewBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> SetViewBuilder<S, St>
where
St: set_view_state::State,
St::Name: set_view_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> SetViewBuilder<S, set_view_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
SetViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SetViewBuilder<S, St>
where
St: set_view_state::State,
St::SetSize: set_view_state::IsUnset,
{
pub fn set_size(
mut self,
value: impl Into<i64>,
) -> SetViewBuilder<S, set_view_state::SetSetSize<St>> {
self._fields.3 = Option::Some(value.into());
SetViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SetViewBuilder<S, St>
where
St: set_view_state::State,
St::UpdatedAt: set_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> SetViewBuilder<S, set_view_state::SetUpdatedAt<St>> {
self._fields.4 = Option::Some(value.into());
SetViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SetViewBuilder<S, St>
where
St: set_view_state::State,
St::CreatedAt: set_view_state::IsSet,
St::SetSize: set_view_state::IsSet,
St::UpdatedAt: set_view_state::IsSet,
St::Name: set_view_state::IsSet,
{
pub fn build(self) -> SetView<S> {
SetView {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
name: self._fields.2.unwrap(),
set_size: self._fields.3.unwrap(),
updated_at: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SetView<S> {
SetView {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
name: self._fields.2.unwrap(),
set_size: self._fields.3.unwrap(),
updated_at: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}