#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::uk_skyblur::preference;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "uk.skyblur.preference",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Preference<S: BosStr = DefaultStr> {
pub my_page: preference::MyPage<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")]
pub struct PreferenceGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Preference<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MyPage<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub is_use_my_page: bool,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Preference<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, PreferenceRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PreferenceRecord;
impl XrpcResp for PreferenceRecord {
const NSID: &'static str = "uk.skyblur.preference";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = PreferenceGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<PreferenceGetRecordOutput<S>> for Preference<S> {
fn from(output: PreferenceGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Preference<S> {
const NSID: &'static str = "uk.skyblur.preference";
type Record = PreferenceRecord;
}
impl Collection for PreferenceRecord {
const NSID: &'static str = "uk.skyblur.preference";
type Record = PreferenceRecord;
}
impl<S: BosStr> LexiconSchema for Preference<S> {
fn nsid() -> &'static str {
"uk.skyblur.preference"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_uk_skyblur_preference()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for MyPage<S> {
fn nsid() -> &'static str {
"uk.skyblur.preference"
}
fn def_name() -> &'static str {
"myPage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_uk_skyblur_preference()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.description {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 100000usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod preference_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 MyPage;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type MyPage = Unset;
}
pub struct SetMyPage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMyPage<St> {}
impl<St: State> State for SetMyPage<St> {
type MyPage = Set<members::my_page>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct my_page(());
}
}
pub struct PreferenceBuilder<S: BosStr, St: preference_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<preference::MyPage<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Preference<S> {
pub fn new() -> PreferenceBuilder<S, preference_state::Empty> {
PreferenceBuilder::new()
}
}
impl<S: BosStr> PreferenceBuilder<S, preference_state::Empty> {
pub fn new() -> Self {
PreferenceBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PreferenceBuilder<S, St>
where
St: preference_state::State,
St::MyPage: preference_state::IsUnset,
{
pub fn my_page(
mut self,
value: impl Into<preference::MyPage<S>>,
) -> PreferenceBuilder<S, preference_state::SetMyPage<St>> {
self._fields.0 = Option::Some(value.into());
PreferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PreferenceBuilder<S, St>
where
St: preference_state::State,
St::MyPage: preference_state::IsSet,
{
pub fn build(self) -> Preference<S> {
Preference {
my_page: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> Preference<S> {
Preference {
my_page: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_uk_skyblur_preference() -> 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("uk.skyblur.preference"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("A declaration of a Skyblur account."),
),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![SmolStr::new_static("myPage")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("myPage"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("uk.skyblur.preference#myPage")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("myPage"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("isUseMyPage")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Define the description displayed on MyPage.",
),
),
max_length: Some(10000usize),
max_graphemes: Some(100000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isUseMyPage"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod my_page_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 IsUseMyPage;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type IsUseMyPage = Unset;
}
pub struct SetIsUseMyPage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIsUseMyPage<St> {}
impl<St: State> State for SetIsUseMyPage<St> {
type IsUseMyPage = Set<members::is_use_my_page>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct is_use_my_page(());
}
}
pub struct MyPageBuilder<S: BosStr, St: my_page_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<bool>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> MyPage<S> {
pub fn new() -> MyPageBuilder<S, my_page_state::Empty> {
MyPageBuilder::new()
}
}
impl<S: BosStr> MyPageBuilder<S, my_page_state::Empty> {
pub fn new() -> Self {
MyPageBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: my_page_state::State> MyPageBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> MyPageBuilder<S, St>
where
St: my_page_state::State,
St::IsUseMyPage: my_page_state::IsUnset,
{
pub fn is_use_my_page(
mut self,
value: impl Into<bool>,
) -> MyPageBuilder<S, my_page_state::SetIsUseMyPage<St>> {
self._fields.1 = Option::Some(value.into());
MyPageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MyPageBuilder<S, St>
where
St: my_page_state::State,
St::IsUseMyPage: my_page_state::IsSet,
{
pub fn build(self) -> MyPage<S> {
MyPage {
description: self._fields.0,
is_use_my_page: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> MyPage<S> {
MyPage {
description: self._fields.0,
is_use_my_page: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}