#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
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;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Preference<'a> {
#[serde(borrow)]
pub my_page: preference::MyPage<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PreferenceGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Preference<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MyPage<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
pub is_use_my_page: bool,
}
impl<'a> Preference<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, PreferenceRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = PreferenceGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<PreferenceGetRecordOutput<'_>> for Preference<'_> {
fn from(output: PreferenceGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Preference<'_> {
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<'a> LexiconSchema for Preference<'a> {
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<'a> LexiconSchema for MyPage<'a> {
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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMyPage<S> {}
impl<S: State> State for SetMyPage<S> {
type MyPage = Set<members::my_page>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct my_page(());
}
}
pub struct PreferenceBuilder<'a, S: preference_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<preference::MyPage<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Preference<'a> {
pub fn new() -> PreferenceBuilder<'a, preference_state::Empty> {
PreferenceBuilder::new()
}
}
impl<'a> PreferenceBuilder<'a, preference_state::Empty> {
pub fn new() -> Self {
PreferenceBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> PreferenceBuilder<'a, S>
where
S: preference_state::State,
S::MyPage: preference_state::IsUnset,
{
pub fn my_page(
mut self,
value: impl Into<preference::MyPage<'a>>,
) -> PreferenceBuilder<'a, preference_state::SetMyPage<S>> {
self._fields.0 = Option::Some(value.into());
PreferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PreferenceBuilder<'a, S>
where
S: preference_state::State,
S::MyPage: preference_state::IsSet,
{
pub fn build(self) -> Preference<'a> {
Preference {
my_page: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Preference<'a> {
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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIsUseMyPage<S> {}
impl<S: State> State for SetIsUseMyPage<S> {
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<'a, S: my_page_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<bool>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> MyPage<'a> {
pub fn new() -> MyPageBuilder<'a, my_page_state::Empty> {
MyPageBuilder::new()
}
}
impl<'a> MyPageBuilder<'a, my_page_state::Empty> {
pub fn new() -> Self {
MyPageBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: my_page_state::State> MyPageBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> MyPageBuilder<'a, S>
where
S: my_page_state::State,
S::IsUseMyPage: my_page_state::IsUnset,
{
pub fn is_use_my_page(
mut self,
value: impl Into<bool>,
) -> MyPageBuilder<'a, my_page_state::SetIsUseMyPage<S>> {
self._fields.1 = Option::Some(value.into());
MyPageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MyPageBuilder<'a, S>
where
S: my_page_state::State,
S::IsUseMyPage: my_page_state::IsSet,
{
pub fn build(self) -> MyPage<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> MyPage<'a> {
MyPage {
description: self._fields.0,
is_use_my_page: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}