From b66a4e63f1ac9f37cf531a74b4271d84703be428 Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Wed, 4 Mar 2026 23:05:56 -0800 Subject: [PATCH] generate bindings --- jong-db/src/db/bot_table.rs | 2 - jong-db/src/db/bot_type.rs | 18 +- jong-db/src/db/clear_all_reducer.rs | 62 ------ jong-db/src/db/game_timer_table.rs | 90 ++++---- jong-db/src/db/game_timer_type.rs | 57 ------ jong-db/src/db/hand_view_type.rs | 7 +- jong-db/src/db/lobby_table.rs | 1 - jong-db/src/db/lobby_timer_type.rs | 57 ++++++ jong-db/src/db/lobby_type.rs | 5 +- jong-db/src/db/mod.rs | 75 ++++--- jong-db/src/db/player_clock_table.rs | 31 --- jong-db/src/db/player_clock_type.rs | 5 - jong-db/src/db/player_config_table.rs | 159 +++++++++++++++ jong-db/src/db/player_config_type.rs | 58 ++++++ jong-db/src/db/player_hand_type.rs | 11 +- jong-db/src/db/player_or_bot_type.rs | 17 -- jong-db/src/db/player_table.rs | 192 ------------------ jong-db/src/db/player_type.rs | 68 ------- jong-db/src/db/user_type.rs | 62 ++++++ jong-db/src/db/view_closed_hands_table.rs | 1 - .../src/db/{db_wall_type.rs => wall_type.rs} | 32 +-- jong-db/src/lib.rs | 9 - 22 files changed, 445 insertions(+), 574 deletions(-) delete mode 100644 jong-db/src/db/clear_all_reducer.rs delete mode 100644 jong-db/src/db/game_timer_type.rs create mode 100644 jong-db/src/db/lobby_timer_type.rs create mode 100644 jong-db/src/db/player_config_table.rs create mode 100644 jong-db/src/db/player_config_type.rs delete mode 100644 jong-db/src/db/player_or_bot_type.rs delete mode 100644 jong-db/src/db/player_table.rs delete mode 100644 jong-db/src/db/player_type.rs create mode 100644 jong-db/src/db/user_type.rs rename jong-db/src/db/{db_wall_type.rs => wall_type.rs} (60%) diff --git a/jong-db/src/db/bot_table.rs b/jong-db/src/db/bot_table.rs index 0c81cf5..73bc154 100644 --- a/jong-db/src/db/bot_table.rs +++ b/jong-db/src/db/bot_table.rs @@ -3,8 +3,6 @@ #![allow(unused, clippy::all)] use super::bot_type::Bot; -use super::db_tile_type::DbTile; -use super::turn_state_type::TurnState; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `bot`. diff --git a/jong-db/src/db/bot_type.rs b/jong-db/src/db/bot_type.rs index 5981868..a49650a 100644 --- a/jong-db/src/db/bot_type.rs +++ b/jong-db/src/db/bot_type.rs @@ -4,18 +4,12 @@ #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -use super::db_tile_type::DbTile; -use super::turn_state_type::TurnState; - #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct Bot { pub id: u32, pub lobby_id: u32, - pub turn_state: TurnState, - pub hand: Vec, - pub pond: Vec, - pub working_tile: Option, + pub config_id: u32, } impl __sdk::InModule for Bot { @@ -28,10 +22,7 @@ impl __sdk::InModule for Bot { pub struct BotCols { pub id: __sdk::__query_builder::Col, pub lobby_id: __sdk::__query_builder::Col, - pub turn_state: __sdk::__query_builder::Col, - pub hand: __sdk::__query_builder::Col>, - pub pond: __sdk::__query_builder::Col>, - pub working_tile: __sdk::__query_builder::Col>, + pub config_id: __sdk::__query_builder::Col, } impl __sdk::__query_builder::HasCols for Bot { @@ -40,10 +31,7 @@ impl __sdk::__query_builder::HasCols for Bot { BotCols { id: __sdk::__query_builder::Col::new(table_name, "id"), lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), - turn_state: __sdk::__query_builder::Col::new(table_name, "turn_state"), - hand: __sdk::__query_builder::Col::new(table_name, "hand"), - pond: __sdk::__query_builder::Col::new(table_name, "pond"), - working_tile: __sdk::__query_builder::Col::new(table_name, "working_tile"), + config_id: __sdk::__query_builder::Col::new(table_name, "config_id"), } } } diff --git a/jong-db/src/db/clear_all_reducer.rs b/jong-db/src/db/clear_all_reducer.rs deleted file mode 100644 index 49a6454..0000000 --- a/jong-db/src/db/clear_all_reducer.rs +++ /dev/null @@ -1,62 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -#![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] -pub(super) struct ClearAllArgs {} - -impl From for super::Reducer { - fn from(args: ClearAllArgs) -> Self { - Self::ClearAll - } -} - -impl __sdk::InModule for ClearAllArgs { - type Module = super::RemoteModule; -} - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `clear_all`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait clear_all { - /// Request that the remote module invoke the reducer `clear_all` to run as soon as possible. - /// - /// This method returns immediately, and errors only if we are unable to send the request. - /// The reducer will run asynchronously in the future, - /// and this method provides no way to listen for its completion status. - /// /// Use [`clear_all:clear_all_then`] to run a callback after the reducer completes. - fn clear_all(&self) -> __sdk::Result<()> { - self.clear_all_then(|_, _| {}) - } - - /// Request that the remote module invoke the reducer `clear_all` to run as soon as possible, - /// registering `callback` to run when we are notified that the reducer completed. - /// - /// This method returns immediately, and errors only if we are unable to send the request. - /// The reducer will run asynchronously in the future, - /// and its status can be observed with the `callback`. - fn clear_all_then( - &self, - - callback: impl FnOnce(&super::ReducerEventContext, Result, __sdk::InternalError>) - + Send - + 'static, - ) -> __sdk::Result<()>; -} - -impl clear_all for super::RemoteReducers { - fn clear_all_then( - &self, - - callback: impl FnOnce(&super::ReducerEventContext, Result, __sdk::InternalError>) - + Send - + 'static, - ) -> __sdk::Result<()> { - self.imp - .invoke_reducer_with_callback(ClearAllArgs {}, callback) - } -} diff --git a/jong-db/src/db/game_timer_table.rs b/jong-db/src/db/game_timer_table.rs index 2aa5ed2..55cea89 100644 --- a/jong-db/src/db/game_timer_table.rs +++ b/jong-db/src/db/game_timer_table.rs @@ -2,7 +2,7 @@ // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. #![allow(unused, clippy::all)] -use super::game_timer_type::GameTimer; +use super::lobby_timer_type::LobbyTimer; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `game_timer`. @@ -14,7 +14,7 @@ use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// but to directly chain method calls, /// like `ctx.db.game_timer().on_insert(...)`. pub struct GameTimerTableHandle<'ctx> { - imp: __sdk::TableHandle, + imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -31,7 +31,7 @@ pub trait GameTimerTableAccess { impl GameTimerTableAccess for super::RemoteTables { fn game_timer(&self) -> GameTimerTableHandle<'_> { GameTimerTableHandle { - imp: self.imp.get_table::("game_timer"), + imp: self.imp.get_table::("game_timer"), ctx: std::marker::PhantomData, } } @@ -41,13 +41,13 @@ pub struct GameTimerInsertCallbackId(__sdk::CallbackId); pub struct GameTimerDeleteCallbackId(__sdk::CallbackId); impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> { - type Row = GameTimer; + type Row = LobbyTimer; type EventContext = super::EventContext; fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } @@ -95,36 +95,6 @@ impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> { } } -/// Access to the `id` unique index on the table `game_timer`, -/// which allows point queries on the field of the same name -/// via the [`GameTimerIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.game_timer().id().find(...)`. -pub struct GameTimerIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> GameTimerTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `game_timer`. - pub fn id(&self) -> GameTimerIdUnique<'ctx> { - GameTimerIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } -} - -impl<'ctx> GameTimerIdUnique<'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: &u64) -> Option { - self.imp.find(col_val) - } -} - /// Access to the `lobby_id` unique index on the table `game_timer`, /// which allows point queries on the field of the same name /// via the [`GameTimerLobbyIdUnique::find`] method. @@ -133,7 +103,7 @@ impl<'ctx> GameTimerIdUnique<'ctx> { /// but to directly chain method calls, /// like `ctx.db.game_timer().lobby_id().find(...)`. pub struct GameTimerLobbyIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, + imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } @@ -150,41 +120,71 @@ impl<'ctx> GameTimerTableHandle<'ctx> { impl<'ctx> GameTimerLobbyIdUnique<'ctx> { /// Find the subscribed row whose `lobby_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 { + pub fn find(&self, col_val: &u32) -> Option { + self.imp.find(col_val) + } +} + +/// Access to the `scheduled_id` unique index on the table `game_timer`, +/// which allows point queries on the field of the same name +/// via the [`GameTimerScheduledIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.game_timer().scheduled_id().find(...)`. +pub struct GameTimerScheduledIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +impl<'ctx> GameTimerTableHandle<'ctx> { + /// Get a handle on the `scheduled_id` unique index on the table `game_timer`. + pub fn scheduled_id(&self) -> GameTimerScheduledIdUnique<'ctx> { + GameTimerScheduledIdUnique { + imp: self.imp.get_unique_constraint::("scheduled_id"), + phantom: std::marker::PhantomData, + } + } +} + +impl<'ctx> GameTimerScheduledIdUnique<'ctx> { + /// Find the subscribed row whose `scheduled_id` column value is equal to `col_val`, + /// if such a row is present in the client cache. + pub fn find(&self, col_val: &u64) -> Option { self.imp.find(col_val) } } #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("game_timer"); - _table.add_unique_constraint::("id", |row| &row.id); + let _table = client_cache.get_or_make_table::("game_timer"); _table.add_unique_constraint::("lobby_id", |row| &row.lobby_id); + _table.add_unique_constraint::("scheduled_id", |row| &row.scheduled_id); } #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::v2::TableUpdate, -) -> __sdk::Result<__sdk::TableUpdate> { +) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") .with_cause(e) .into() }) } #[allow(non_camel_case_types)] -/// Extension trait for query builder access to the table `GameTimer`. +/// Extension trait for query builder access to the table `LobbyTimer`. /// /// Implemented for [`__sdk::QueryTableAccessor`]. pub trait game_timerQueryTableAccess { #[allow(non_snake_case)] - /// Get a query builder for the table `GameTimer`. - fn game_timer(&self) -> __sdk::__query_builder::Table; + /// Get a query builder for the table `LobbyTimer`. + fn game_timer(&self) -> __sdk::__query_builder::Table; } impl game_timerQueryTableAccess for __sdk::QueryTableAccessor { - fn game_timer(&self) -> __sdk::__query_builder::Table { + fn game_timer(&self) -> __sdk::__query_builder::Table { __sdk::__query_builder::Table::new("game_timer") } } diff --git a/jong-db/src/db/game_timer_type.rs b/jong-db/src/db/game_timer_type.rs deleted file mode 100644 index 31d3fa3..0000000 --- a/jong-db/src/db/game_timer_type.rs +++ /dev/null @@ -1,57 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -#![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] -pub struct GameTimer { - pub id: u64, - pub lobby_id: u32, - pub scheduled_at: __sdk::ScheduleAt, -} - -impl __sdk::InModule for GameTimer { - type Module = super::RemoteModule; -} - -/// Column accessor struct for the table `GameTimer`. -/// -/// Provides typed access to columns for query building. -pub struct GameTimerCols { - pub id: __sdk::__query_builder::Col, - pub lobby_id: __sdk::__query_builder::Col, - pub scheduled_at: __sdk::__query_builder::Col, -} - -impl __sdk::__query_builder::HasCols for GameTimer { - type Cols = GameTimerCols; - fn cols(table_name: &'static str) -> Self::Cols { - GameTimerCols { - id: __sdk::__query_builder::Col::new(table_name, "id"), - lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), - scheduled_at: __sdk::__query_builder::Col::new(table_name, "scheduled_at"), - } - } -} - -/// Indexed column accessor struct for the table `GameTimer`. -/// -/// Provides typed access to indexed columns for query building. -pub struct GameTimerIxCols { - pub id: __sdk::__query_builder::IxCol, - pub lobby_id: __sdk::__query_builder::IxCol, -} - -impl __sdk::__query_builder::HasIxCols for GameTimer { - type IxCols = GameTimerIxCols; - fn ix_cols(table_name: &'static str) -> Self::IxCols { - GameTimerIxCols { - id: __sdk::__query_builder::IxCol::new(table_name, "id"), - lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), - } - } -} - -impl __sdk::__query_builder::CanBeLookupTable for GameTimer {} diff --git a/jong-db/src/db/hand_view_type.rs b/jong-db/src/db/hand_view_type.rs index 3fe49b3..bc75638 100644 --- a/jong-db/src/db/hand_view_type.rs +++ b/jong-db/src/db/hand_view_type.rs @@ -5,12 +5,11 @@ use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::db_tile_type::DbTile; -use super::player_or_bot_type::PlayerOrBot; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct HandView { - pub player: PlayerOrBot, + pub player_id: u32, pub hand_length: u8, pub pond: Vec, pub drawn: bool, @@ -24,7 +23,7 @@ impl __sdk::InModule for HandView { /// /// Provides typed access to columns for query building. pub struct HandViewCols { - pub player: __sdk::__query_builder::Col, + pub player_id: __sdk::__query_builder::Col, pub hand_length: __sdk::__query_builder::Col, pub pond: __sdk::__query_builder::Col>, pub drawn: __sdk::__query_builder::Col, @@ -34,7 +33,7 @@ impl __sdk::__query_builder::HasCols for HandView { type Cols = HandViewCols; fn cols(table_name: &'static str) -> Self::Cols { HandViewCols { - player: __sdk::__query_builder::Col::new(table_name, "player"), + player_id: __sdk::__query_builder::Col::new(table_name, "player_id"), hand_length: __sdk::__query_builder::Col::new(table_name, "hand_length"), pond: __sdk::__query_builder::Col::new(table_name, "pond"), drawn: __sdk::__query_builder::Col::new(table_name, "drawn"), diff --git a/jong-db/src/db/lobby_table.rs b/jong-db/src/db/lobby_table.rs index 696c723..02144a5 100644 --- a/jong-db/src/db/lobby_table.rs +++ b/jong-db/src/db/lobby_table.rs @@ -4,7 +4,6 @@ #![allow(unused, clippy::all)] use super::game_state_type::GameState; use super::lobby_type::Lobby; -use super::player_or_bot_type::PlayerOrBot; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `lobby`. diff --git a/jong-db/src/db/lobby_timer_type.rs b/jong-db/src/db/lobby_timer_type.rs new file mode 100644 index 0000000..beb8419 --- /dev/null +++ b/jong-db/src/db/lobby_timer_type.rs @@ -0,0 +1,57 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#![allow(unused, clippy::all)] +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct LobbyTimer { + pub lobby_id: u32, + pub scheduled_id: u64, + pub scheduled_at: __sdk::ScheduleAt, +} + +impl __sdk::InModule for LobbyTimer { + type Module = super::RemoteModule; +} + +/// Column accessor struct for the table `LobbyTimer`. +/// +/// Provides typed access to columns for query building. +pub struct LobbyTimerCols { + pub lobby_id: __sdk::__query_builder::Col, + pub scheduled_id: __sdk::__query_builder::Col, + pub scheduled_at: __sdk::__query_builder::Col, +} + +impl __sdk::__query_builder::HasCols for LobbyTimer { + type Cols = LobbyTimerCols; + fn cols(table_name: &'static str) -> Self::Cols { + LobbyTimerCols { + lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), + scheduled_id: __sdk::__query_builder::Col::new(table_name, "scheduled_id"), + scheduled_at: __sdk::__query_builder::Col::new(table_name, "scheduled_at"), + } + } +} + +/// Indexed column accessor struct for the table `LobbyTimer`. +/// +/// Provides typed access to indexed columns for query building. +pub struct LobbyTimerIxCols { + pub lobby_id: __sdk::__query_builder::IxCol, + pub scheduled_id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for LobbyTimer { + type IxCols = LobbyTimerIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + LobbyTimerIxCols { + lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), + scheduled_id: __sdk::__query_builder::IxCol::new(table_name, "scheduled_id"), + } + } +} + +impl __sdk::__query_builder::CanBeLookupTable for LobbyTimer {} diff --git a/jong-db/src/db/lobby_type.rs b/jong-db/src/db/lobby_type.rs index 942a58a..f442ff8 100644 --- a/jong-db/src/db/lobby_type.rs +++ b/jong-db/src/db/lobby_type.rs @@ -5,13 +5,12 @@ use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::game_state_type::GameState; -use super::player_or_bot_type::PlayerOrBot; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct Lobby { pub id: u32, - pub players: Vec, + pub players: Vec, pub dealer_idx: u8, pub current_idx: u8, pub game_state: GameState, @@ -26,7 +25,7 @@ impl __sdk::InModule for Lobby { /// Provides typed access to columns for query building. pub struct LobbyCols { pub id: __sdk::__query_builder::Col, - pub players: __sdk::__query_builder::Col>, + pub players: __sdk::__query_builder::Col>, pub dealer_idx: __sdk::__query_builder::Col, pub current_idx: __sdk::__query_builder::Col, pub game_state: __sdk::__query_builder::Col, diff --git a/jong-db/src/db/mod.rs b/jong-db/src/db/mod.rs index 83e4053..c8a61cd 100644 --- a/jong-db/src/db/mod.rs +++ b/jong-db/src/db/mod.rs @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 2.0.1 (commit a4d29daec8ed35ce4913a335b7210b9ae3933d00). +// This was generated using spacetimedb cli version 2.0.2 (commit bc4fcec6f33f607fb46f61ae66c479eecf5a6e74). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; @@ -10,62 +10,60 @@ pub mod add_bot_reducer; pub mod advance_game_reducer; pub mod bot_table; pub mod bot_type; -pub mod clear_all_reducer; pub mod db_tile_type; -pub mod db_wall_type; pub mod discard_tile_reducer; pub mod dragon_type; pub mod game_state_type; pub mod game_timer_table; -pub mod game_timer_type; pub mod hand_view_type; pub mod join_or_create_lobby_reducer; pub mod lobby_table; +pub mod lobby_timer_type; pub mod lobby_type; pub mod player_clock_table; pub mod player_clock_type; +pub mod player_config_table; +pub mod player_config_type; pub mod player_hand_type; -pub mod player_or_bot_type; -pub mod player_table; -pub mod player_type; pub mod rank_type; pub mod set_ready_reducer; pub mod suit_type; pub mod tile_type; pub mod turn_state_type; +pub mod user_type; pub mod view_closed_hands_table; pub mod view_hand_table; +pub mod wall_type; pub mod wind_type; pub use add_bot_reducer::add_bot; pub use advance_game_reducer::advance_game; pub use bot_table::*; pub use bot_type::Bot; -pub use clear_all_reducer::clear_all; pub use db_tile_type::DbTile; -pub use db_wall_type::DbWall; pub use discard_tile_reducer::discard_tile; pub use dragon_type::Dragon; pub use game_state_type::GameState; pub use game_timer_table::*; -pub use game_timer_type::GameTimer; pub use hand_view_type::HandView; pub use join_or_create_lobby_reducer::join_or_create_lobby; pub use lobby_table::*; +pub use lobby_timer_type::LobbyTimer; pub use lobby_type::Lobby; pub use player_clock_table::*; pub use player_clock_type::PlayerClock; +pub use player_config_table::*; +pub use player_config_type::PlayerConfig; pub use player_hand_type::PlayerHand; -pub use player_or_bot_type::PlayerOrBot; -pub use player_table::*; -pub use player_type::Player; pub use rank_type::Rank; pub use set_ready_reducer::set_ready; pub use suit_type::Suit; pub use tile_type::Tile; pub use turn_state_type::TurnState; +pub use user_type::User; pub use view_closed_hands_table::*; pub use view_hand_table::*; +pub use wall_type::Wall; pub use wind_type::Wind; #[derive(Clone, PartialEq, Debug)] @@ -78,7 +76,6 @@ pub use wind_type::Wind; pub enum Reducer { AddBot { lobby_id: u32 }, AdvanceGame, - ClearAll, DiscardTile { tile_id: u32 }, JoinOrCreateLobby { lobby_id: u32 }, SetReady { ready: bool }, @@ -93,7 +90,6 @@ impl __sdk::Reducer for Reducer { match self { Reducer::AddBot { .. } => "add_bot", Reducer::AdvanceGame => "advance_game", - Reducer::ClearAll => "clear_all", Reducer::DiscardTile { .. } => "discard_tile", Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby", Reducer::SetReady { .. } => "set_ready", @@ -109,7 +105,6 @@ impl __sdk::Reducer for Reducer { Reducer::AdvanceGame => { __sats::bsatn::to_vec(&advance_game_reducer::AdvanceGameArgs {}) } - Reducer::ClearAll => __sats::bsatn::to_vec(&clear_all_reducer::ClearAllArgs {}), Reducer::DiscardTile { tile_id } => { __sats::bsatn::to_vec(&discard_tile_reducer::DiscardTileArgs { tile_id: tile_id.clone(), @@ -135,10 +130,10 @@ impl __sdk::Reducer for Reducer { #[doc(hidden)] pub struct DbUpdate { bot: __sdk::TableUpdate, - game_timer: __sdk::TableUpdate, + game_timer: __sdk::TableUpdate, lobby: __sdk::TableUpdate, - player: __sdk::TableUpdate, player_clock: __sdk::TableUpdate, + player_config: __sdk::TableUpdate, view_closed_hands: __sdk::TableUpdate, view_hand: __sdk::TableUpdate, } @@ -158,12 +153,12 @@ impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate { "lobby" => db_update .lobby .append(lobby_table::parse_table_update(table_update)?), - "player" => db_update - .player - .append(player_table::parse_table_update(table_update)?), "player_clock" => db_update .player_clock .append(player_clock_table::parse_table_update(table_update)?), + "player_config" => db_update + .player_config + .append(player_config_table::parse_table_update(table_update)?), "view_closed_hands" => db_update .view_closed_hands .append(view_closed_hands_table::parse_table_update(table_update)?), @@ -200,16 +195,16 @@ impl __sdk::DbUpdate for DbUpdate { .apply_diff_to_table::("bot", &self.bot) .with_updates_by_pk(|row| &row.id); diff.game_timer = cache - .apply_diff_to_table::("game_timer", &self.game_timer) - .with_updates_by_pk(|row| &row.id); + .apply_diff_to_table::("game_timer", &self.game_timer) + .with_updates_by_pk(|row| &row.scheduled_id); diff.lobby = cache .apply_diff_to_table::("lobby", &self.lobby) .with_updates_by_pk(|row| &row.id); - diff.player = cache - .apply_diff_to_table::("player", &self.player) - .with_updates_by_pk(|row| &row.identity); diff.player_clock = cache .apply_diff_to_table::("player_clock", &self.player_clock) + .with_updates_by_pk(|row| &row.player_id); + diff.player_config = cache + .apply_diff_to_table::("player_config", &self.player_config) .with_updates_by_pk(|row| &row.id); diff.view_closed_hands = cache.apply_diff_to_table::("view_closed_hands", &self.view_closed_hands); @@ -230,12 +225,12 @@ impl __sdk::DbUpdate for DbUpdate { "lobby" => db_update .lobby .append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), - "player" => db_update - .player - .append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "player_clock" => db_update .player_clock .append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), + "player_config" => db_update + .player_config + .append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), "view_closed_hands" => db_update .view_closed_hands .append(__sdk::parse_row_list_as_inserts(table_rows.rows)?), @@ -264,12 +259,12 @@ impl __sdk::DbUpdate for DbUpdate { "lobby" => db_update .lobby .append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), - "player" => db_update - .player - .append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "player_clock" => db_update .player_clock .append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), + "player_config" => db_update + .player_config + .append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), "view_closed_hands" => db_update .view_closed_hands .append(__sdk::parse_row_list_as_deletes(table_rows.rows)?), @@ -292,10 +287,10 @@ impl __sdk::DbUpdate for DbUpdate { #[doc(hidden)] pub struct AppliedDiff<'r> { bot: __sdk::TableAppliedDiff<'r, Bot>, - game_timer: __sdk::TableAppliedDiff<'r, GameTimer>, + game_timer: __sdk::TableAppliedDiff<'r, LobbyTimer>, lobby: __sdk::TableAppliedDiff<'r, Lobby>, - player: __sdk::TableAppliedDiff<'r, Player>, player_clock: __sdk::TableAppliedDiff<'r, PlayerClock>, + player_config: __sdk::TableAppliedDiff<'r, PlayerConfig>, view_closed_hands: __sdk::TableAppliedDiff<'r, HandView>, view_hand: __sdk::TableAppliedDiff<'r, PlayerHand>, __unused: std::marker::PhantomData<&'r ()>, @@ -312,14 +307,18 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> { callbacks: &mut __sdk::DbCallbacks, ) { callbacks.invoke_table_row_callbacks::("bot", &self.bot, event); - callbacks.invoke_table_row_callbacks::("game_timer", &self.game_timer, event); + callbacks.invoke_table_row_callbacks::("game_timer", &self.game_timer, event); callbacks.invoke_table_row_callbacks::("lobby", &self.lobby, event); - callbacks.invoke_table_row_callbacks::("player", &self.player, event); callbacks.invoke_table_row_callbacks::( "player_clock", &self.player_clock, event, ); + callbacks.invoke_table_row_callbacks::( + "player_config", + &self.player_config, + event, + ); callbacks.invoke_table_row_callbacks::( "view_closed_hands", &self.view_closed_hands, @@ -973,8 +972,8 @@ impl __sdk::SpacetimeModule for RemoteModule { bot_table::register_table(client_cache); game_timer_table::register_table(client_cache); lobby_table::register_table(client_cache); - player_table::register_table(client_cache); player_clock_table::register_table(client_cache); + player_config_table::register_table(client_cache); view_closed_hands_table::register_table(client_cache); view_hand_table::register_table(client_cache); } @@ -982,8 +981,8 @@ impl __sdk::SpacetimeModule for RemoteModule { "bot", "game_timer", "lobby", - "player", "player_clock", + "player_config", "view_closed_hands", "view_hand", ]; diff --git a/jong-db/src/db/player_clock_table.rs b/jong-db/src/db/player_clock_table.rs index 82093ad..5f1983b 100644 --- a/jong-db/src/db/player_clock_table.rs +++ b/jong-db/src/db/player_clock_table.rs @@ -95,36 +95,6 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerClockTableHandle<'ctx> { } } -/// Access to the `id` unique index on the table `player_clock`, -/// which allows point queries on the field of the same name -/// via the [`PlayerClockIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.player_clock().id().find(...)`. -pub struct PlayerClockIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> PlayerClockTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `player_clock`. - pub fn id(&self) -> PlayerClockIdUnique<'ctx> { - PlayerClockIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } -} - -impl<'ctx> PlayerClockIdUnique<'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 { - self.imp.find(col_val) - } -} - /// Access to the `player_id` unique index on the table `player_clock`, /// which allows point queries on the field of the same name /// via the [`PlayerClockPlayerIdUnique::find`] method. @@ -158,7 +128,6 @@ impl<'ctx> PlayerClockPlayerIdUnique<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { let _table = client_cache.get_or_make_table::("player_clock"); - _table.add_unique_constraint::("id", |row| &row.id); _table.add_unique_constraint::("player_id", |row| &row.player_id); } diff --git a/jong-db/src/db/player_clock_type.rs b/jong-db/src/db/player_clock_type.rs index 59998c7..791ee13 100644 --- a/jong-db/src/db/player_clock_type.rs +++ b/jong-db/src/db/player_clock_type.rs @@ -7,7 +7,6 @@ use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct PlayerClock { - pub id: u32, pub player_id: u32, pub renewable: u16, pub total: u16, @@ -21,7 +20,6 @@ impl __sdk::InModule for PlayerClock { /// /// Provides typed access to columns for query building. pub struct PlayerClockCols { - pub id: __sdk::__query_builder::Col, pub player_id: __sdk::__query_builder::Col, pub renewable: __sdk::__query_builder::Col, pub total: __sdk::__query_builder::Col, @@ -31,7 +29,6 @@ impl __sdk::__query_builder::HasCols for PlayerClock { type Cols = PlayerClockCols; fn cols(table_name: &'static str) -> Self::Cols { PlayerClockCols { - id: __sdk::__query_builder::Col::new(table_name, "id"), player_id: __sdk::__query_builder::Col::new(table_name, "player_id"), renewable: __sdk::__query_builder::Col::new(table_name, "renewable"), total: __sdk::__query_builder::Col::new(table_name, "total"), @@ -43,7 +40,6 @@ impl __sdk::__query_builder::HasCols for PlayerClock { /// /// Provides typed access to indexed columns for query building. pub struct PlayerClockIxCols { - pub id: __sdk::__query_builder::IxCol, pub player_id: __sdk::__query_builder::IxCol, } @@ -51,7 +47,6 @@ impl __sdk::__query_builder::HasIxCols for PlayerClock { type IxCols = PlayerClockIxCols; fn ix_cols(table_name: &'static str) -> Self::IxCols { PlayerClockIxCols { - id: __sdk::__query_builder::IxCol::new(table_name, "id"), player_id: __sdk::__query_builder::IxCol::new(table_name, "player_id"), } } diff --git a/jong-db/src/db/player_config_table.rs b/jong-db/src/db/player_config_table.rs new file mode 100644 index 0000000..a7baa2e --- /dev/null +++ b/jong-db/src/db/player_config_table.rs @@ -0,0 +1,159 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#![allow(unused, clippy::all)] +use super::player_config_type::PlayerConfig; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `player_config`. +/// +/// Obtain a handle from the [`PlayerConfigTableAccess::player_config`] method on [`super::RemoteTables`], +/// like `ctx.db.player_config()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_config().on_insert(...)`. +pub struct PlayerConfigTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `player_config`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait PlayerConfigTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`PlayerConfigTableHandle`], which mediates access to the table `player_config`. + fn player_config(&self) -> PlayerConfigTableHandle<'_>; +} + +impl PlayerConfigTableAccess for super::RemoteTables { + fn player_config(&self) -> PlayerConfigTableHandle<'_> { + PlayerConfigTableHandle { + imp: self.imp.get_table::("player_config"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct PlayerConfigInsertCallbackId(__sdk::CallbackId); +pub struct PlayerConfigDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for PlayerConfigTableHandle<'ctx> { + type Row = PlayerConfig; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = PlayerConfigInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerConfigInsertCallbackId { + PlayerConfigInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: PlayerConfigInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = PlayerConfigDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerConfigDeleteCallbackId { + PlayerConfigDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: PlayerConfigDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +pub struct PlayerConfigUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for PlayerConfigTableHandle<'ctx> { + type UpdateCallbackId = PlayerConfigUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> PlayerConfigUpdateCallbackId { + PlayerConfigUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: PlayerConfigUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + +/// Access to the `id` unique index on the table `player_config`, +/// which allows point queries on the field of the same name +/// via the [`PlayerConfigIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_config().id().find(...)`. +pub struct PlayerConfigIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +impl<'ctx> PlayerConfigTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `player_config`. + pub fn id(&self) -> PlayerConfigIdUnique<'ctx> { + PlayerConfigIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, + } + } +} + +impl<'ctx> PlayerConfigIdUnique<'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 { + self.imp.find(col_val) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("player_config"); + _table.add_unique_constraint::("id", |row| &row.id); +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::v2::TableUpdate, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() + }) +} + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `PlayerConfig`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait player_configQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `PlayerConfig`. + fn player_config(&self) -> __sdk::__query_builder::Table; +} + +impl player_configQueryTableAccess for __sdk::QueryTableAccessor { + fn player_config(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("player_config") + } +} diff --git a/jong-db/src/db/player_config_type.rs b/jong-db/src/db/player_config_type.rs new file mode 100644 index 0000000..7ddd007 --- /dev/null +++ b/jong-db/src/db/player_config_type.rs @@ -0,0 +1,58 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#![allow(unused, clippy::all)] +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct PlayerConfig { + pub id: u32, + pub name: String, + pub ready: bool, + pub sort: bool, +} + +impl __sdk::InModule for PlayerConfig { + type Module = super::RemoteModule; +} + +/// Column accessor struct for the table `PlayerConfig`. +/// +/// Provides typed access to columns for query building. +pub struct PlayerConfigCols { + pub id: __sdk::__query_builder::Col, + pub name: __sdk::__query_builder::Col, + pub ready: __sdk::__query_builder::Col, + pub sort: __sdk::__query_builder::Col, +} + +impl __sdk::__query_builder::HasCols for PlayerConfig { + type Cols = PlayerConfigCols; + fn cols(table_name: &'static str) -> Self::Cols { + PlayerConfigCols { + id: __sdk::__query_builder::Col::new(table_name, "id"), + name: __sdk::__query_builder::Col::new(table_name, "name"), + ready: __sdk::__query_builder::Col::new(table_name, "ready"), + sort: __sdk::__query_builder::Col::new(table_name, "sort"), + } + } +} + +/// Indexed column accessor struct for the table `PlayerConfig`. +/// +/// Provides typed access to indexed columns for query building. +pub struct PlayerConfigIxCols { + pub id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for PlayerConfig { + type IxCols = PlayerConfigIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + PlayerConfigIxCols { + id: __sdk::__query_builder::IxCol::new(table_name, "id"), + } + } +} + +impl __sdk::__query_builder::CanBeLookupTable for PlayerConfig {} diff --git a/jong-db/src/db/player_hand_type.rs b/jong-db/src/db/player_hand_type.rs index 6715afa..658116c 100644 --- a/jong-db/src/db/player_hand_type.rs +++ b/jong-db/src/db/player_hand_type.rs @@ -10,11 +10,10 @@ use super::turn_state_type::TurnState; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct PlayerHand { - pub id: u32, pub player_id: u32, pub turn_state: TurnState, - pub pond: Vec, pub hand: Vec, + pub pond: Vec, pub working_tile: Option, } @@ -26,11 +25,10 @@ impl __sdk::InModule for PlayerHand { /// /// Provides typed access to columns for query building. pub struct PlayerHandCols { - pub id: __sdk::__query_builder::Col, pub player_id: __sdk::__query_builder::Col, pub turn_state: __sdk::__query_builder::Col, - pub pond: __sdk::__query_builder::Col>, pub hand: __sdk::__query_builder::Col>, + pub pond: __sdk::__query_builder::Col>, pub working_tile: __sdk::__query_builder::Col>, } @@ -38,11 +36,10 @@ impl __sdk::__query_builder::HasCols for PlayerHand { type Cols = PlayerHandCols; fn cols(table_name: &'static str) -> Self::Cols { PlayerHandCols { - id: __sdk::__query_builder::Col::new(table_name, "id"), player_id: __sdk::__query_builder::Col::new(table_name, "player_id"), turn_state: __sdk::__query_builder::Col::new(table_name, "turn_state"), - pond: __sdk::__query_builder::Col::new(table_name, "pond"), hand: __sdk::__query_builder::Col::new(table_name, "hand"), + pond: __sdk::__query_builder::Col::new(table_name, "pond"), working_tile: __sdk::__query_builder::Col::new(table_name, "working_tile"), } } @@ -52,7 +49,6 @@ impl __sdk::__query_builder::HasCols for PlayerHand { /// /// Provides typed access to indexed columns for query building. pub struct PlayerHandIxCols { - pub id: __sdk::__query_builder::IxCol, pub player_id: __sdk::__query_builder::IxCol, } @@ -60,7 +56,6 @@ impl __sdk::__query_builder::HasIxCols for PlayerHand { type IxCols = PlayerHandIxCols; fn ix_cols(table_name: &'static str) -> Self::IxCols { PlayerHandIxCols { - id: __sdk::__query_builder::IxCol::new(table_name, "id"), player_id: __sdk::__query_builder::IxCol::new(table_name, "player_id"), } } diff --git a/jong-db/src/db/player_or_bot_type.rs b/jong-db/src/db/player_or_bot_type.rs deleted file mode 100644 index 538d940..0000000 --- a/jong-db/src/db/player_or_bot_type.rs +++ /dev/null @@ -1,17 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -#![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] -pub enum PlayerOrBot { - Player(u32), - - Bot(u32), -} - -impl __sdk::InModule for PlayerOrBot { - type Module = super::RemoteModule; -} diff --git a/jong-db/src/db/player_table.rs b/jong-db/src/db/player_table.rs deleted file mode 100644 index 7972a6e..0000000 --- a/jong-db/src/db/player_table.rs +++ /dev/null @@ -1,192 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -#![allow(unused, clippy::all)] -use super::player_type::Player; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -/// Table handle for the table `player`. -/// -/// Obtain a handle from the [`PlayerTableAccess::player`] method on [`super::RemoteTables`], -/// like `ctx.db.player()`. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.player().on_insert(...)`. -pub struct PlayerTableHandle<'ctx> { - imp: __sdk::TableHandle, - ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -#[allow(non_camel_case_types)] -/// Extension trait for access to the table `player`. -/// -/// Implemented for [`super::RemoteTables`]. -pub trait PlayerTableAccess { - #[allow(non_snake_case)] - /// Obtain a [`PlayerTableHandle`], which mediates access to the table `player`. - fn player(&self) -> PlayerTableHandle<'_>; -} - -impl PlayerTableAccess for super::RemoteTables { - fn player(&self) -> PlayerTableHandle<'_> { - PlayerTableHandle { - imp: self.imp.get_table::("player"), - ctx: std::marker::PhantomData, - } - } -} - -pub struct PlayerInsertCallbackId(__sdk::CallbackId); -pub struct PlayerDeleteCallbackId(__sdk::CallbackId); - -impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> { - type Row = Player; - type EventContext = super::EventContext; - - fn count(&self) -> u64 { - self.imp.count() - } - fn iter(&self) -> impl Iterator + '_ { - self.imp.iter() - } - - type InsertCallbackId = PlayerInsertCallbackId; - - fn on_insert( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> PlayerInsertCallbackId { - PlayerInsertCallbackId(self.imp.on_insert(Box::new(callback))) - } - - fn remove_on_insert(&self, callback: PlayerInsertCallbackId) { - self.imp.remove_on_insert(callback.0) - } - - type DeleteCallbackId = PlayerDeleteCallbackId; - - fn on_delete( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> PlayerDeleteCallbackId { - PlayerDeleteCallbackId(self.imp.on_delete(Box::new(callback))) - } - - fn remove_on_delete(&self, callback: PlayerDeleteCallbackId) { - self.imp.remove_on_delete(callback.0) - } -} - -pub struct PlayerUpdateCallbackId(__sdk::CallbackId); - -impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> { - type UpdateCallbackId = PlayerUpdateCallbackId; - - fn on_update( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, - ) -> PlayerUpdateCallbackId { - PlayerUpdateCallbackId(self.imp.on_update(Box::new(callback))) - } - - fn remove_on_update(&self, callback: PlayerUpdateCallbackId) { - self.imp.remove_on_update(callback.0) - } -} - -/// Access to the `id` unique index on the table `player`, -/// which allows point queries on the field of the same name -/// via the [`PlayerIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.player().id().find(...)`. -pub struct PlayerIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> PlayerTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `player`. - pub fn id(&self) -> PlayerIdUnique<'ctx> { - PlayerIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } -} - -impl<'ctx> PlayerIdUnique<'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 { - self.imp.find(col_val) - } -} - -/// Access to the `identity` unique index on the table `player`, -/// which allows point queries on the field of the same name -/// via the [`PlayerIdentityUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.player().identity().find(...)`. -pub struct PlayerIdentityUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> PlayerTableHandle<'ctx> { - /// Get a handle on the `identity` unique index on the table `player`. - pub fn identity(&self) -> PlayerIdentityUnique<'ctx> { - PlayerIdentityUnique { - imp: self - .imp - .get_unique_constraint::<__sdk::Identity>("identity"), - phantom: std::marker::PhantomData, - } - } -} - -impl<'ctx> PlayerIdentityUnique<'ctx> { - /// Find the subscribed row whose `identity` column value is equal to `col_val`, - /// if such a row is present in the client cache. - pub fn find(&self, col_val: &__sdk::Identity) -> Option { - self.imp.find(col_val) - } -} - -#[doc(hidden)] -pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("player"); - _table.add_unique_constraint::("id", |row| &row.id); - _table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity); -} - -#[doc(hidden)] -pub(super) fn parse_table_update( - raw_updates: __ws::v2::TableUpdate, -) -> __sdk::Result<__sdk::TableUpdate> { - __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() - }) -} - -#[allow(non_camel_case_types)] -/// Extension trait for query builder access to the table `Player`. -/// -/// Implemented for [`__sdk::QueryTableAccessor`]. -pub trait playerQueryTableAccess { - #[allow(non_snake_case)] - /// Get a query builder for the table `Player`. - fn player(&self) -> __sdk::__query_builder::Table; -} - -impl playerQueryTableAccess for __sdk::QueryTableAccessor { - fn player(&self) -> __sdk::__query_builder::Table { - __sdk::__query_builder::Table::new("player") - } -} diff --git a/jong-db/src/db/player_type.rs b/jong-db/src/db/player_type.rs deleted file mode 100644 index a4b8634..0000000 --- a/jong-db/src/db/player_type.rs +++ /dev/null @@ -1,68 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -#![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] -pub struct Player { - pub id: u32, - pub identity: __sdk::Identity, - pub name: Option, - pub lobby_id: u32, - pub ready: bool, - pub sort: bool, -} - -impl __sdk::InModule for Player { - type Module = super::RemoteModule; -} - -/// Column accessor struct for the table `Player`. -/// -/// Provides typed access to columns for query building. -pub struct PlayerCols { - pub id: __sdk::__query_builder::Col, - pub identity: __sdk::__query_builder::Col, - pub name: __sdk::__query_builder::Col>, - pub lobby_id: __sdk::__query_builder::Col, - pub ready: __sdk::__query_builder::Col, - pub sort: __sdk::__query_builder::Col, -} - -impl __sdk::__query_builder::HasCols for Player { - type Cols = PlayerCols; - fn cols(table_name: &'static str) -> Self::Cols { - PlayerCols { - id: __sdk::__query_builder::Col::new(table_name, "id"), - identity: __sdk::__query_builder::Col::new(table_name, "identity"), - name: __sdk::__query_builder::Col::new(table_name, "name"), - lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), - ready: __sdk::__query_builder::Col::new(table_name, "ready"), - sort: __sdk::__query_builder::Col::new(table_name, "sort"), - } - } -} - -/// Indexed column accessor struct for the table `Player`. -/// -/// Provides typed access to indexed columns for query building. -pub struct PlayerIxCols { - pub id: __sdk::__query_builder::IxCol, - pub identity: __sdk::__query_builder::IxCol, - pub lobby_id: __sdk::__query_builder::IxCol, -} - -impl __sdk::__query_builder::HasIxCols for Player { - type IxCols = PlayerIxCols; - fn ix_cols(table_name: &'static str) -> Self::IxCols { - PlayerIxCols { - id: __sdk::__query_builder::IxCol::new(table_name, "id"), - identity: __sdk::__query_builder::IxCol::new(table_name, "identity"), - lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), - } - } -} - -impl __sdk::__query_builder::CanBeLookupTable for Player {} diff --git a/jong-db/src/db/user_type.rs b/jong-db/src/db/user_type.rs new file mode 100644 index 0000000..0f99ca8 --- /dev/null +++ b/jong-db/src/db/user_type.rs @@ -0,0 +1,62 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#![allow(unused, clippy::all)] +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct User { + pub identity: __sdk::Identity, + pub name: String, + pub lobby_id: u32, + pub config_id: u32, +} + +impl __sdk::InModule for User { + type Module = super::RemoteModule; +} + +/// Column accessor struct for the table `User`. +/// +/// Provides typed access to columns for query building. +pub struct UserCols { + pub identity: __sdk::__query_builder::Col, + pub name: __sdk::__query_builder::Col, + pub lobby_id: __sdk::__query_builder::Col, + pub config_id: __sdk::__query_builder::Col, +} + +impl __sdk::__query_builder::HasCols for User { + type Cols = UserCols; + fn cols(table_name: &'static str) -> Self::Cols { + UserCols { + identity: __sdk::__query_builder::Col::new(table_name, "identity"), + name: __sdk::__query_builder::Col::new(table_name, "name"), + lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), + config_id: __sdk::__query_builder::Col::new(table_name, "config_id"), + } + } +} + +/// Indexed column accessor struct for the table `User`. +/// +/// Provides typed access to indexed columns for query building. +pub struct UserIxCols { + pub config_id: __sdk::__query_builder::IxCol, + pub identity: __sdk::__query_builder::IxCol, + pub lobby_id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for User { + type IxCols = UserIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + UserIxCols { + config_id: __sdk::__query_builder::IxCol::new(table_name, "config_id"), + identity: __sdk::__query_builder::IxCol::new(table_name, "identity"), + lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), + } + } +} + +impl __sdk::__query_builder::CanBeLookupTable for User {} diff --git a/jong-db/src/db/view_closed_hands_table.rs b/jong-db/src/db/view_closed_hands_table.rs index ab1b296..613dbee 100644 --- a/jong-db/src/db/view_closed_hands_table.rs +++ b/jong-db/src/db/view_closed_hands_table.rs @@ -4,7 +4,6 @@ #![allow(unused, clippy::all)] use super::db_tile_type::DbTile; use super::hand_view_type::HandView; -use super::player_or_bot_type::PlayerOrBot; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `view_closed_hands`. diff --git a/jong-db/src/db/db_wall_type.rs b/jong-db/src/db/wall_type.rs similarity index 60% rename from jong-db/src/db/db_wall_type.rs rename to jong-db/src/db/wall_type.rs index 6d46d7f..c173096 100644 --- a/jong-db/src/db/db_wall_type.rs +++ b/jong-db/src/db/wall_type.rs @@ -8,47 +8,47 @@ use super::db_tile_type::DbTile; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] -pub struct DbWall { +pub struct Wall { pub lobby_id: u32, pub tiles: Vec, } -impl __sdk::InModule for DbWall { +impl __sdk::InModule for Wall { type Module = super::RemoteModule; } -/// Column accessor struct for the table `DbWall`. +/// Column accessor struct for the table `Wall`. /// /// Provides typed access to columns for query building. -pub struct DbWallCols { - pub lobby_id: __sdk::__query_builder::Col, - pub tiles: __sdk::__query_builder::Col>, +pub struct WallCols { + pub lobby_id: __sdk::__query_builder::Col, + pub tiles: __sdk::__query_builder::Col>, } -impl __sdk::__query_builder::HasCols for DbWall { - type Cols = DbWallCols; +impl __sdk::__query_builder::HasCols for Wall { + type Cols = WallCols; fn cols(table_name: &'static str) -> Self::Cols { - DbWallCols { + WallCols { lobby_id: __sdk::__query_builder::Col::new(table_name, "lobby_id"), tiles: __sdk::__query_builder::Col::new(table_name, "tiles"), } } } -/// Indexed column accessor struct for the table `DbWall`. +/// Indexed column accessor struct for the table `Wall`. /// /// Provides typed access to indexed columns for query building. -pub struct DbWallIxCols { - pub lobby_id: __sdk::__query_builder::IxCol, +pub struct WallIxCols { + pub lobby_id: __sdk::__query_builder::IxCol, } -impl __sdk::__query_builder::HasIxCols for DbWall { - type IxCols = DbWallIxCols; +impl __sdk::__query_builder::HasIxCols for Wall { + type IxCols = WallIxCols; fn ix_cols(table_name: &'static str) -> Self::IxCols { - DbWallIxCols { + WallIxCols { lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), } } } -impl __sdk::__query_builder::CanBeLookupTable for DbWall {} +impl __sdk::__query_builder::CanBeLookupTable for Wall {} diff --git a/jong-db/src/lib.rs b/jong-db/src/lib.rs index 46735ab..0d3befb 100644 --- a/jong-db/src/lib.rs +++ b/jong-db/src/lib.rs @@ -55,13 +55,4 @@ mod conversions { Self::from_repr(value as usize).unwrap() } } - - impl From<&crate::db::PlayerOrBot> for jong_types::PlayerOrBot { - fn from(value: &crate::db::PlayerOrBot) -> Self { - match value { - crate::PlayerOrBot::Player(id) => Self::Player { id: *id }, - crate::PlayerOrBot::Bot(id) => Self::Bot { id: *id }, - } - } - } }