#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
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::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "net.anisota.player.state",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct State<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub active_blocks_intention_daily: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_intention_consuming7d: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_intention_creating7d: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_intention_total7d: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_intention_x: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_intention_y: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub current_light: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub current_stamina: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub equipped: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_session_start: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub light_drain_active: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub slot_capacity: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub starter_items_granted: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub trigger_source: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tutorial_completed_at: Option<Datetime>,
pub updated_at: Datetime,
#[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 StateGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: State<S>,
}
impl<S: BosStr> State<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, StateRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct StateRecord;
impl XrpcResp for StateRecord {
const NSID: &'static str = "net.anisota.player.state";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = StateGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<StateGetRecordOutput<S>> for State<S> {
fn from(output: StateGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for State<S> {
const NSID: &'static str = "net.anisota.player.state";
type Record = StateRecord;
}
impl Collection for StateRecord {
const NSID: &'static str = "net.anisota.player.state";
type Record = StateRecord;
}
impl<S: BosStr> LexiconSchema for State<S> {
fn nsid() -> &'static str {
"net.anisota.player.state"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_net_anisota_player_state()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod state_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 UpdatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UpdatedAt = Unset;
}
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 UpdatedAt = Set<members::updated_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
}
}
pub struct StateBuilder<St: state_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Data<S>>,
Option<Datetime>,
Option<bool>,
Option<Data<S>>,
Option<bool>,
Option<S>,
Option<Datetime>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl State<DefaultStr> {
pub fn new() -> StateBuilder<state_state::Empty, DefaultStr> {
StateBuilder::new()
}
}
impl<S: BosStr> State<S> {
pub fn builder() -> StateBuilder<state_state::Empty, S> {
StateBuilder::builder()
}
}
impl StateBuilder<state_state::Empty, DefaultStr> {
pub fn new() -> Self {
StateBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr> StateBuilder<state_state::Empty, S> {
pub fn builder() -> Self {
StateBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None,
),
_type: PhantomData,
}
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn active_blocks_intention_daily(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_active_blocks_intention_daily(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn activity_intention_consuming7d(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_activity_intention_consuming7d(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn activity_intention_creating7d(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_activity_intention_creating7d(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn activity_intention_total7d(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_activity_intention_total7d(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn activity_intention_x(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_activity_intention_x(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn activity_intention_y(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_activity_intention_y(mut self, value: Option<S>) -> Self {
self._fields.5 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn current_light(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_current_light(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn current_stamina(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_current_stamina(mut self, value: Option<S>) -> Self {
self._fields.7 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn equipped(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_equipped(mut self, value: Option<Data<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn last_session_start(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_last_session_start(mut self, value: Option<Datetime>) -> Self {
self._fields.9 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn light_drain_active(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_light_drain_active(mut self, value: Option<bool>) -> Self {
self._fields.10 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn slot_capacity(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.11 = value.into();
self
}
pub fn maybe_slot_capacity(mut self, value: Option<Data<S>>) -> Self {
self._fields.11 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn starter_items_granted(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_starter_items_granted(mut self, value: Option<bool>) -> Self {
self._fields.12 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn trigger_source(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.13 = value.into();
self
}
pub fn maybe_trigger_source(mut self, value: Option<S>) -> Self {
self._fields.13 = value;
self
}
}
impl<St: state_state::State, S: BosStr> StateBuilder<St, S> {
pub fn tutorial_completed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.14 = value.into();
self
}
pub fn maybe_tutorial_completed_at(mut self, value: Option<Datetime>) -> Self {
self._fields.14 = value;
self
}
}
impl<St, S: BosStr> StateBuilder<St, S>
where
St: state_state::State,
St::UpdatedAt: state_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> StateBuilder<state_state::SetUpdatedAt<St>, S> {
self._fields.15 = Option::Some(value.into());
StateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StateBuilder<St, S>
where
St: state_state::State,
St::UpdatedAt: state_state::IsSet,
{
pub fn build(self) -> State<S> {
State {
active_blocks_intention_daily: self._fields.0,
activity_intention_consuming7d: self._fields.1,
activity_intention_creating7d: self._fields.2,
activity_intention_total7d: self._fields.3,
activity_intention_x: self._fields.4,
activity_intention_y: self._fields.5,
current_light: self._fields.6,
current_stamina: self._fields.7,
equipped: self._fields.8,
last_session_start: self._fields.9,
light_drain_active: self._fields.10,
slot_capacity: self._fields.11,
starter_items_granted: self._fields.12,
trigger_source: self._fields.13,
tutorial_completed_at: self._fields.14,
updated_at: self._fields.15.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> State<S> {
State {
active_blocks_intention_daily: self._fields.0,
activity_intention_consuming7d: self._fields.1,
activity_intention_creating7d: self._fields.2,
activity_intention_total7d: self._fields.3,
activity_intention_x: self._fields.4,
activity_intention_y: self._fields.5,
current_light: self._fields.6,
current_stamina: self._fields.7,
equipped: self._fields.8,
last_session_start: self._fields.9,
light_drain_active: self._fields.10,
slot_capacity: self._fields.11,
starter_items_granted: self._fields.12,
trigger_source: self._fields.13,
tutorial_completed_at: self._fields.14,
updated_at: self._fields.15.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_net_anisota_player_state() -> 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("net.anisota.player.state"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Ephemeral player state for cross-device sync. Singleton record (rkey: self), overwritten via putRecord.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![SmolStr::new_static("updatedAt")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("activeBlocksIntentionDaily"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Target active blocks per day (decimal string, e.g. '6')",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("activityIntentionConsuming7d"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Deprecated: use activityIntentionTotal7d. Target weekly consuming count.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("activityIntentionCreating7d"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Deprecated: use activityIntentionTotal7d. Target weekly creating count.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("activityIntentionTotal7d"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Target total weekly activity count, sum of all actions (decimal string, e.g. '500')",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("activityIntentionX"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Activity style intention X position as grid percentage (0-100, consuming axis)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("activityIntentionY"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Activity style intention Y position as grid percentage (0-100, creating axis)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("currentLight"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Current light charge in Wh (decimal string, e.g. '280.0')",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("currentStamina"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Current stamina level (decimal string, e.g. '42.5')",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("equipped"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lastSessionStart"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the current session started (for multi-device awareness)",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lightDrainActive"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("slotCapacity"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("starterItemsGranted"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("triggerSource"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"What caused this state snapshot (visibility_hidden, session_end, stamina_depleted, manual)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tutorialCompletedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"When the player completed (or skipped) the interactive tutorial. Presence of this field means the tutorial is done; absence means it has not been completed.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("When this state snapshot was taken"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}