#[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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, RecordKey, Rkey};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::dev_tsunagite::game;
use crate::dev_tsunagite::types::Indexable;
#[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 Enum<S: BosStr = DefaultStr> {
pub id: RecordKey<Rkey<S>>,
pub name: Data<S>,
pub values: Vec<Indexable<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",
rename = "dev.tsunagite.game",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Game<S: BosStr = DefaultStr> {
pub default_component: RecordKey<Rkey<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub input_methods: Option<Vec<S>>,
pub judgments: Vec<Indexable<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub logo: Option<BlobRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub modes: Option<Vec<S>>,
pub name: Data<S>,
pub score_components: Vec<GameScoreComponentsItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum GameScoreComponentsItem<S: BosStr = DefaultStr> {
#[serde(rename = "dev.tsunagite.game#enum")]
Enum(Box<game::Enum<S>>),
#[serde(rename = "dev.tsunagite.game#points")]
Points(Box<game::Points<S>>),
#[serde(rename = "dev.tsunagite.game#percentage")]
Percentage(Box<game::Percentage<S>>),
#[serde(rename = "dev.tsunagite.game#text")]
Text(Box<game::Text<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GameGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Game<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Percentage<S: BosStr = DefaultStr> {
pub id: RecordKey<Rkey<S>>,
#[serde(default = "_default_percentage_maximum")]
pub maximum: i64,
pub name: Data<S>,
#[serde(default = "_default_percentage_precision")]
pub precision: i64,
#[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 Points<S: BosStr = DefaultStr> {
pub id: RecordKey<Rkey<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<i64>,
pub name: Data<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 Text<S: BosStr = DefaultStr> {
pub id: RecordKey<Rkey<S>>,
pub name: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Game<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, GameRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Enum<S> {
fn nsid() -> &'static str {
"dev.tsunagite.game"
}
fn def_name() -> &'static str {
"enum"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_tsunagite_game()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("id"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct GameRecord;
impl XrpcResp for GameRecord {
const NSID: &'static str = "dev.tsunagite.game";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = GameGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<GameGetRecordOutput<S>> for Game<S> {
fn from(output: GameGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Game<S> {
const NSID: &'static str = "dev.tsunagite.game";
type Record = GameRecord;
}
impl Collection for GameRecord {
const NSID: &'static str = "dev.tsunagite.game";
type Record = GameRecord;
}
impl<S: BosStr> LexiconSchema for Game<S> {
fn nsid() -> &'static str {
"dev.tsunagite.game"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_tsunagite_game()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.logo {
{
let size = value.blob().size;
if size > 8000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("logo"),
max: 8000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.logo {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg", "image/jxl", "image/webp"];
let matched = accepted.iter().any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix) && mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("logo"),
accepted: vec![
"image/png".to_string(),
"image/jpeg".to_string(),
"image/jxl".to_string(),
"image/webp".to_string(),
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Percentage<S> {
fn nsid() -> &'static str {
"dev.tsunagite.game"
}
fn def_name() -> &'static str {
"percentage"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_tsunagite_game()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("id"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Points<S> {
fn nsid() -> &'static str {
"dev.tsunagite.game"
}
fn def_name() -> &'static str {
"points"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_tsunagite_game()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("id"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Text<S> {
fn nsid() -> &'static str {
"dev.tsunagite.game"
}
fn def_name() -> &'static str {
"text"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_tsunagite_game()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("id"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.id;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 1usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("id"),
min: 1usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod enum_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 Id;
type Values;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Values = Unset;
type Name = Unset;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Id = Set<members::id>;
type Values = St::Values;
type Name = St::Name;
}
pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValues<St> {}
impl<St: State> State for SetValues<St> {
type Id = St::Id;
type Values = Set<members::values>;
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 Id = St::Id;
type Values = St::Values;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct values(());
pub struct name(());
}
}
pub struct EnumBuilder<S: BosStr, St: enum_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<RecordKey<Rkey<S>>>,
Option<Data<S>>,
Option<Vec<Indexable<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Enum<S> {
pub fn new() -> EnumBuilder<S, enum_state::Empty> {
EnumBuilder::new()
}
}
impl<S: BosStr> EnumBuilder<S, enum_state::Empty> {
pub fn new() -> Self {
EnumBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnumBuilder<S, St>
where
St: enum_state::State,
St::Id: enum_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> EnumBuilder<S, enum_state::SetId<St>> {
self._fields.0 = Option::Some(value.into());
EnumBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnumBuilder<S, St>
where
St: enum_state::State,
St::Name: enum_state::IsUnset,
{
pub fn name(mut self, value: impl Into<Data<S>>) -> EnumBuilder<S, enum_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
EnumBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnumBuilder<S, St>
where
St: enum_state::State,
St::Values: enum_state::IsUnset,
{
pub fn values(
mut self,
value: impl Into<Vec<Indexable<S>>>,
) -> EnumBuilder<S, enum_state::SetValues<St>> {
self._fields.2 = Option::Some(value.into());
EnumBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnumBuilder<S, St>
where
St: enum_state::State,
St::Id: enum_state::IsSet,
St::Values: enum_state::IsSet,
St::Name: enum_state::IsSet,
{
pub fn build(self) -> Enum<S> {
Enum {
id: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
values: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Enum<S> {
Enum {
id: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
values: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_dev_tsunagite_game() -> 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("dev.tsunagite.game"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("enum"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("A closed set of indexable named values."),
),
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("id"),
SmolStr::new_static("values")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The internal ID of this component, limited to the RecordKey characterset.",
),
),
format: Some(LexStringFormat::RecordKey),
min_length: Some(1usize),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.translatable"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("values"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"The allowed values for this enum to take.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.types#indexable"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A record describing a game hosting leaderboards via Tsunagite.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("name"),
SmolStr::new_static("judgments"),
SmolStr::new_static("scoreComponents"),
SmolStr::new_static("defaultComponent")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("defaultComponent"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The default component for leaderboard sorting.",
),
),
format: Some(LexStringFormat::RecordKey),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("inputMethods"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"An array of usable input methods for the game. Optional if the game only has one input method or doesn't separate leaderboards by method.",
),
),
items: LexArrayItem::String(LexString {
description: Some(
CowStr::new_static("Can be tokens or raw strings."),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("judgments"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"The obtainable judgments during gameplay.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.types#indexable"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("logo"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("modes"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"An array of playable game modes with different gameplay configurations. Optional if the game only has one mode.",
),
),
items: LexArrayItem::String(LexString {
description: Some(
CowStr::new_static("Can be tokens or raw strings."),
),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.translatable"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scoreComponents"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"All the components of a score in the game, including grades, lamps, EX score, and whatever other constructs are used.",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#enum"), CowStr::new_static("#points"),
CowStr::new_static("#percentage"),
CowStr::new_static("#text")
],
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("percentage"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A percentage score with customizable precision.",
),
),
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("id"),
SmolStr::new_static("maximum"),
SmolStr::new_static("precision")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The internal ID of this component, limited to the RecordKey characterset.",
),
),
format: Some(LexStringFormat::RecordKey),
min_length: Some(1usize),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maximum"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.translatable"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("precision"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("points"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"An integer point score, with or without a cap.",
),
),
required: Some(
vec![SmolStr::new_static("name"), SmolStr::new_static("id")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The internal ID of this component, limited to the RecordKey characterset.",
),
),
format: Some(LexStringFormat::RecordKey),
min_length: Some(1usize),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("maximum"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.translatable"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A fallback component for displaying arbitrary text.",
),
),
required: Some(
vec![SmolStr::new_static("name"), SmolStr::new_static("id")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The internal ID of this component, limited to the RecordKey characterset.",
),
),
format: Some(LexStringFormat::RecordKey),
min_length: Some(1usize),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("dev.tsunagite.translatable"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod game_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 Judgments;
type Name;
type ScoreComponents;
type DefaultComponent;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Judgments = Unset;
type Name = Unset;
type ScoreComponents = Unset;
type DefaultComponent = Unset;
}
pub struct SetJudgments<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetJudgments<St> {}
impl<St: State> State for SetJudgments<St> {
type Judgments = Set<members::judgments>;
type Name = St::Name;
type ScoreComponents = St::ScoreComponents;
type DefaultComponent = St::DefaultComponent;
}
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 Judgments = St::Judgments;
type Name = Set<members::name>;
type ScoreComponents = St::ScoreComponents;
type DefaultComponent = St::DefaultComponent;
}
pub struct SetScoreComponents<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetScoreComponents<St> {}
impl<St: State> State for SetScoreComponents<St> {
type Judgments = St::Judgments;
type Name = St::Name;
type ScoreComponents = Set<members::score_components>;
type DefaultComponent = St::DefaultComponent;
}
pub struct SetDefaultComponent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDefaultComponent<St> {}
impl<St: State> State for SetDefaultComponent<St> {
type Judgments = St::Judgments;
type Name = St::Name;
type ScoreComponents = St::ScoreComponents;
type DefaultComponent = Set<members::default_component>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct judgments(());
pub struct name(());
pub struct score_components(());
pub struct default_component(());
}
}
pub struct GameBuilder<S: BosStr, St: game_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<RecordKey<Rkey<S>>>,
Option<Vec<S>>,
Option<Vec<Indexable<S>>>,
Option<BlobRef<S>>,
Option<Vec<S>>,
Option<Data<S>>,
Option<Vec<GameScoreComponentsItem<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Game<S> {
pub fn new() -> GameBuilder<S, game_state::Empty> {
GameBuilder::new()
}
}
impl<S: BosStr> GameBuilder<S, game_state::Empty> {
pub fn new() -> Self {
GameBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GameBuilder<S, St>
where
St: game_state::State,
St::DefaultComponent: game_state::IsUnset,
{
pub fn default_component(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> GameBuilder<S, game_state::SetDefaultComponent<St>> {
self._fields.0 = Option::Some(value.into());
GameBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: game_state::State> GameBuilder<S, St> {
pub fn input_methods(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_input_methods(mut self, value: Option<Vec<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> GameBuilder<S, St>
where
St: game_state::State,
St::Judgments: game_state::IsUnset,
{
pub fn judgments(
mut self,
value: impl Into<Vec<Indexable<S>>>,
) -> GameBuilder<S, game_state::SetJudgments<St>> {
self._fields.2 = Option::Some(value.into());
GameBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: game_state::State> GameBuilder<S, St> {
pub fn logo(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_logo(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: game_state::State> GameBuilder<S, St> {
pub fn modes(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_modes(mut self, value: Option<Vec<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> GameBuilder<S, St>
where
St: game_state::State,
St::Name: game_state::IsUnset,
{
pub fn name(mut self, value: impl Into<Data<S>>) -> GameBuilder<S, game_state::SetName<St>> {
self._fields.5 = Option::Some(value.into());
GameBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GameBuilder<S, St>
where
St: game_state::State,
St::ScoreComponents: game_state::IsUnset,
{
pub fn score_components(
mut self,
value: impl Into<Vec<GameScoreComponentsItem<S>>>,
) -> GameBuilder<S, game_state::SetScoreComponents<St>> {
self._fields.6 = Option::Some(value.into());
GameBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GameBuilder<S, St>
where
St: game_state::State,
St::Judgments: game_state::IsSet,
St::Name: game_state::IsSet,
St::ScoreComponents: game_state::IsSet,
St::DefaultComponent: game_state::IsSet,
{
pub fn build(self) -> Game<S> {
Game {
default_component: self._fields.0.unwrap(),
input_methods: self._fields.1,
judgments: self._fields.2.unwrap(),
logo: self._fields.3,
modes: self._fields.4,
name: self._fields.5.unwrap(),
score_components: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Game<S> {
Game {
default_component: self._fields.0.unwrap(),
input_methods: self._fields.1,
judgments: self._fields.2.unwrap(),
logo: self._fields.3,
modes: self._fields.4,
name: self._fields.5.unwrap(),
score_components: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn _default_percentage_maximum() -> i64 {
100i64
}
fn _default_percentage_precision() -> i64 {
2i64
}
pub mod percentage_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 Maximum;
type Id;
type Precision;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Maximum = Unset;
type Id = Unset;
type Precision = Unset;
type Name = Unset;
}
pub struct SetMaximum<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMaximum<St> {}
impl<St: State> State for SetMaximum<St> {
type Maximum = Set<members::maximum>;
type Id = St::Id;
type Precision = St::Precision;
type Name = St::Name;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Maximum = St::Maximum;
type Id = Set<members::id>;
type Precision = St::Precision;
type Name = St::Name;
}
pub struct SetPrecision<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPrecision<St> {}
impl<St: State> State for SetPrecision<St> {
type Maximum = St::Maximum;
type Id = St::Id;
type Precision = Set<members::precision>;
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 Maximum = St::Maximum;
type Id = St::Id;
type Precision = St::Precision;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct maximum(());
pub struct id(());
pub struct precision(());
pub struct name(());
}
}
pub struct PercentageBuilder<S: BosStr, St: percentage_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<RecordKey<Rkey<S>>>,
Option<i64>,
Option<Data<S>>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Percentage<S> {
pub fn new() -> PercentageBuilder<S, percentage_state::Empty> {
PercentageBuilder::new()
}
}
impl<S: BosStr> PercentageBuilder<S, percentage_state::Empty> {
pub fn new() -> Self {
PercentageBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PercentageBuilder<S, St>
where
St: percentage_state::State,
St::Id: percentage_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> PercentageBuilder<S, percentage_state::SetId<St>> {
self._fields.0 = Option::Some(value.into());
PercentageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PercentageBuilder<S, St>
where
St: percentage_state::State,
St::Maximum: percentage_state::IsUnset,
{
pub fn maximum(
mut self,
value: impl Into<i64>,
) -> PercentageBuilder<S, percentage_state::SetMaximum<St>> {
self._fields.1 = Option::Some(value.into());
PercentageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PercentageBuilder<S, St>
where
St: percentage_state::State,
St::Name: percentage_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<Data<S>>,
) -> PercentageBuilder<S, percentage_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
PercentageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PercentageBuilder<S, St>
where
St: percentage_state::State,
St::Precision: percentage_state::IsUnset,
{
pub fn precision(
mut self,
value: impl Into<i64>,
) -> PercentageBuilder<S, percentage_state::SetPrecision<St>> {
self._fields.3 = Option::Some(value.into());
PercentageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PercentageBuilder<S, St>
where
St: percentage_state::State,
St::Maximum: percentage_state::IsSet,
St::Id: percentage_state::IsSet,
St::Precision: percentage_state::IsSet,
St::Name: percentage_state::IsSet,
{
pub fn build(self) -> Percentage<S> {
Percentage {
id: self._fields.0.unwrap(),
maximum: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
precision: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Percentage<S> {
Percentage {
id: self._fields.0.unwrap(),
maximum: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
precision: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod points_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 Id;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Id = Unset;
type Name = Unset;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Id = Set<members::id>;
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 Id = St::Id;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct id(());
pub struct name(());
}
}
pub struct PointsBuilder<S: BosStr, St: points_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<RecordKey<Rkey<S>>>, Option<i64>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Points<S> {
pub fn new() -> PointsBuilder<S, points_state::Empty> {
PointsBuilder::new()
}
}
impl<S: BosStr> PointsBuilder<S, points_state::Empty> {
pub fn new() -> Self {
PointsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PointsBuilder<S, St>
where
St: points_state::State,
St::Id: points_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> PointsBuilder<S, points_state::SetId<St>> {
self._fields.0 = Option::Some(value.into());
PointsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: points_state::State> PointsBuilder<S, St> {
pub fn maximum(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_maximum(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> PointsBuilder<S, St>
where
St: points_state::State,
St::Name: points_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<Data<S>>,
) -> PointsBuilder<S, points_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
PointsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PointsBuilder<S, St>
where
St: points_state::State,
St::Id: points_state::IsSet,
St::Name: points_state::IsSet,
{
pub fn build(self) -> Points<S> {
Points {
id: self._fields.0.unwrap(),
maximum: self._fields.1,
name: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Points<S> {
Points {
id: self._fields.0.unwrap(),
maximum: self._fields.1,
name: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod text_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 Name;
type Id;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Id = Unset;
}
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 Name = Set<members::name>;
type Id = St::Id;
}
pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetId<St> {}
impl<St: State> State for SetId<St> {
type Name = St::Name;
type Id = Set<members::id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct id(());
}
}
pub struct TextBuilder<S: BosStr, St: text_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<RecordKey<Rkey<S>>>, Option<Data<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Text<S> {
pub fn new() -> TextBuilder<S, text_state::Empty> {
TextBuilder::new()
}
}
impl<S: BosStr> TextBuilder<S, text_state::Empty> {
pub fn new() -> Self {
TextBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TextBuilder<S, St>
where
St: text_state::State,
St::Id: text_state::IsUnset,
{
pub fn id(
mut self,
value: impl Into<RecordKey<Rkey<S>>>,
) -> TextBuilder<S, text_state::SetId<St>> {
self._fields.0 = Option::Some(value.into());
TextBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TextBuilder<S, St>
where
St: text_state::State,
St::Name: text_state::IsUnset,
{
pub fn name(mut self, value: impl Into<Data<S>>) -> TextBuilder<S, text_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
TextBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TextBuilder<S, St>
where
St: text_state::State,
St::Name: text_state::IsSet,
St::Id: text_state::IsSet,
{
pub fn build(self) -> Text<S> {
Text {
id: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Text<S> {
Text {
id: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}