state advancer reducer

This commit is contained in:
Tao Tien 2026-02-20 15:36:04 -08:00
parent c12667938e
commit e2c9c815ec
44 changed files with 2063 additions and 773 deletions

View file

@ -2,11 +2,15 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use super::game_state_type::GameState;
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::lobby_type::Lobby;
use super::player_or_bot_type::PlayerOrBot;
use super::turn_state_type::TurnState;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::game_state_type::GameState;
/// Table handle for the table `lobby`.
///
@ -47,12 +51,8 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
type Row = Lobby;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = Lobby> + '_ {
self.imp.iter()
}
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = Lobby> + '_ { self.imp.iter() }
type InsertCallbackId = LobbyInsertCallbackId;
@ -83,9 +83,9 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
_table.add_unique_constraint::<u32>("host_player_id", |row| &row.host_player_id);
}
pub struct LobbyUpdateCallbackId(__sdk::CallbackId);
@ -104,73 +104,46 @@ impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<Lobby>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<Lobby>", "TableUpdate")
.with_cause(e)
.into()
__sdk::InternalError::failed_parse(
"TableUpdate<Lobby>",
"TableUpdate",
).with_cause(e).into()
})
}
/// Access to the `id` unique index on the table `lobby`,
/// which allows point queries on the field of the same name
/// via the [`LobbyIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.lobby().id().find(...)`.
pub struct LobbyIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Lobby, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LobbyTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `lobby`.
pub fn id(&self) -> LobbyIdUnique<'ctx> {
LobbyIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
/// Access to the `id` unique index on the table `lobby`,
/// which allows point queries on the field of the same name
/// via the [`LobbyIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.lobby().id().find(...)`.
pub struct LobbyIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Lobby, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
}
}
impl<'ctx> LobbyIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<Lobby> {
self.imp.find(col_val)
}
}
/// Access to the `host_player_id` unique index on the table `lobby`,
/// which allows point queries on the field of the same name
/// via the [`LobbyHostPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.lobby().host_player_id().find(...)`.
pub struct LobbyHostPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Lobby, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LobbyTableHandle<'ctx> {
/// Get a handle on the `host_player_id` unique index on the table `lobby`.
pub fn host_player_id(&self) -> LobbyHostPlayerIdUnique<'ctx> {
LobbyHostPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("host_player_id"),
phantom: std::marker::PhantomData,
impl<'ctx> LobbyTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `lobby`.
pub fn id(&self) -> LobbyIdUnique<'ctx> {
LobbyIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
}
}
}
impl<'ctx> LobbyHostPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `host_player_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<Lobby> {
self.imp.find(col_val)
}
}
impl<'ctx> LobbyIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<Lobby> {
self.imp.find(col_val)
}
}