From e2c9c815ec1b88b7c98df95ccb2b3f23beb9909b Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:36:04 -0800 Subject: [PATCH 1/5] state advancer reducer --- Cargo.lock | 1 + devenv.nix | 2 +- jong-db/src/db/add_bot_reducer.rs | 44 ++- jong-db/src/db/advance_game_reducer.rs | 109 ++++++ jong-db/src/db/bot_table.rs | 82 ++-- jong-db/src/db/bot_type.rs | 17 +- jong-db/src/db/clear_all_reducer.rs | 43 ++- jong-db/src/db/connect_reducer.rs | 103 +++++ jong-db/src/db/db_tile_type.rs | 9 +- jong-db/src/db/db_wall_type.rs | 11 +- jong-db/src/db/discard_tile_reducer.rs | 45 ++- jong-db/src/db/disconnect_reducer.rs | 103 +++++ jong-db/src/db/dragon_type.rs | 11 +- jong-db/src/db/game_state_type.rs | 11 +- jong-db/src/db/game_timer_table.rs | 178 +++++++++ jong-db/src/db/game_timer_type.rs | 25 ++ .../src/db/join_or_create_lobby_reducer.rs | 51 +-- jong-db/src/db/lobby_table.rs | 111 ++---- jong-db/src/db/lobby_type.rs | 16 +- jong-db/src/db/logged_out_player_table.rs | 178 +++++++++ jong-db/src/db/mod.rs | 364 +++++++----------- jong-db/src/db/player_clock_table.rs | 178 +++++++++ jong-db/src/db/player_clock_type.rs | 26 ++ jong-db/src/db/player_hand_table.rs | 180 +++++++++ jong-db/src/db/player_hand_type.rs | 30 ++ jong-db/src/db/player_or_bot_type.rs | 12 +- jong-db/src/db/player_table.rs | 142 +++---- jong-db/src/db/player_type.rs | 17 +- jong-db/src/db/rank_type.rs | 10 +- jong-db/src/db/set_ready_reducer.rs | 46 ++- jong-db/src/db/suit_type.rs | 13 +- jong-db/src/db/tile_table.rs | 81 ++-- jong-db/src/db/tile_type.rs | 9 +- jong-db/src/db/turn_state_type.rs | 11 +- jong-db/src/db/wall_table.rs | 83 ++-- jong-db/src/db/wind_type.rs | 11 +- jong-line/src/lib.rs | 66 ++-- jong-line/src/reducers.rs | 118 ++++++ jong-line/src/reducers/deal.rs | 37 +- jong-line/src/reducers/hand.rs | 124 ++---- jong-line/src/reducers/lobby.rs | 47 ++- jong-line/src/tables.rs | 70 +++- jong/src/riichi.rs | 10 +- jong/src/tui/input/keyboard.rs | 1 - 44 files changed, 2063 insertions(+), 773 deletions(-) create mode 100644 jong-db/src/db/advance_game_reducer.rs create mode 100644 jong-db/src/db/connect_reducer.rs create mode 100644 jong-db/src/db/disconnect_reducer.rs create mode 100644 jong-db/src/db/game_timer_table.rs create mode 100644 jong-db/src/db/game_timer_type.rs create mode 100644 jong-db/src/db/logged_out_player_table.rs create mode 100644 jong-db/src/db/player_clock_table.rs create mode 100644 jong-db/src/db/player_clock_type.rs create mode 100644 jong-db/src/db/player_hand_table.rs create mode 100644 jong-db/src/db/player_hand_type.rs create mode 100644 jong-line/src/reducers.rs diff --git a/Cargo.lock b/Cargo.lock index 08176cf..b30c07e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1229,6 +1229,7 @@ dependencies = [ "bitflags 2.11.0", "color-eyre", "ratatui", + "smol_str", "tracing", ] diff --git a/devenv.nix b/devenv.nix index af52a59..925cfa6 100644 --- a/devenv.nix +++ b/devenv.nix @@ -18,7 +18,7 @@ # https://devenv.sh/packages/ packages = with pkgs; [ - # lspmux + lspmux pkg-config # spacetimedb diff --git a/jong-db/src/db/add_bot_reducer.rs b/jong-db/src/db/add_bot_reducer.rs index eccf63a..36ed6db 100644 --- a/jong-db/src/db/add_bot_reducer.rs +++ b/jong-db/src/db/add_bot_reducer.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -14,8 +20,8 @@ impl From for super::Reducer { fn from(args: AddBotArgs) -> Self { Self::AddBot { lobby_id: args.lobby_id, - } - } +} +} } impl __sdk::InModule for AddBotArgs { @@ -34,7 +40,8 @@ pub trait add_bot { /// 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 by listening for [`Self::on_add_bot`] callbacks. - fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()>; + fn add_bot(&self, lobby_id: u32, +) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -42,39 +49,35 @@ pub trait add_bot { /// /// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`] /// to cancel the callback. - fn on_add_bot( - &self, - callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, - ) -> AddBotCallbackId; + fn on_add_bot(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> AddBotCallbackId; /// Cancel a callback previously registered by [`Self::on_add_bot`], /// causing it not to run in the future. fn remove_on_add_bot(&self, callback: AddBotCallbackId); } impl add_bot for super::RemoteReducers { - fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()> { - self.imp.call_reducer("add_bot", AddBotArgs { lobby_id }) + fn add_bot(&self, lobby_id: u32, +) -> __sdk::Result<()> { + self.imp.call_reducer("add_bot", AddBotArgs { lobby_id, }) } fn on_add_bot( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, ) -> AddBotCallbackId { AddBotCallbackId(self.imp.on_reducer( "add_bot", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::AddBot { lobby_id }, - .. + event: __sdk::ReducerEvent { + reducer: super::Reducer::AddBot { + lobby_id, }, + .. + }, .. - } = ctx - else { - unreachable!() - }; - callback(ctx, lobby_id) + } = ctx else { unreachable!() }; + callback(ctx, lobby_id, ) }), )) } @@ -102,3 +105,4 @@ impl set_flags_for_add_bot for super::SetReducerFlags { self.imp.set_call_reducer_flags("add_bot", flags); } } + diff --git a/jong-db/src/db/advance_game_reducer.rs b/jong-db/src/db/advance_game_reducer.rs new file mode 100644 index 0000000..fbd576f --- /dev/null +++ b/jong-db/src/db/advance_game_reducer.rs @@ -0,0 +1,109 @@ +// 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, +}; + +use super::game_timer_type::GameTimer; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub(super) struct AdvanceGameArgs { + pub game_timer: GameTimer, +} + +impl From for super::Reducer { + fn from(args: AdvanceGameArgs) -> Self { + Self::AdvanceGame { + game_timer: args.game_timer, +} +} +} + +impl __sdk::InModule for AdvanceGameArgs { + type Module = super::RemoteModule; +} + +pub struct AdvanceGameCallbackId(__sdk::CallbackId); + +#[allow(non_camel_case_types)] +/// Extension trait for access to the reducer `advance_game`. +/// +/// Implemented for [`super::RemoteReducers`]. +pub trait advance_game { + /// Request that the remote module invoke the reducer `advance_game` 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 its status can be observed by listening for [`Self::on_advance_game`] callbacks. + fn advance_game(&self, game_timer: GameTimer, +) -> __sdk::Result<()>; + /// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`. + /// + /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] + /// to determine the reducer's status. + /// + /// The returned [`AdvanceGameCallbackId`] can be passed to [`Self::remove_on_advance_game`] + /// to cancel the callback. + fn on_advance_game(&self, callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static) -> AdvanceGameCallbackId; + /// Cancel a callback previously registered by [`Self::on_advance_game`], + /// causing it not to run in the future. + fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId); +} + +impl advance_game for super::RemoteReducers { + fn advance_game(&self, game_timer: GameTimer, +) -> __sdk::Result<()> { + self.imp.call_reducer("advance_game", AdvanceGameArgs { game_timer, }) + } + fn on_advance_game( + &self, + mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static, + ) -> AdvanceGameCallbackId { + AdvanceGameCallbackId(self.imp.on_reducer( + "advance_game", + Box::new(move |ctx: &super::ReducerEventContext| { + #[allow(irrefutable_let_patterns)] + let super::ReducerEventContext { + event: __sdk::ReducerEvent { + reducer: super::Reducer::AdvanceGame { + game_timer, + }, + .. + }, + .. + } = ctx else { unreachable!() }; + callback(ctx, game_timer, ) + }), + )) + } + fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId) { + self.imp.remove_on_reducer("advance_game", callback.0) + } +} + +#[allow(non_camel_case_types)] +#[doc(hidden)] +/// Extension trait for setting the call-flags for the reducer `advance_game`. +/// +/// Implemented for [`super::SetReducerFlags`]. +/// +/// This type is currently unstable and may be removed without a major version bump. +pub trait set_flags_for_advance_game { + /// Set the call-reducer flags for the reducer `advance_game` to `flags`. + /// + /// This type is currently unstable and may be removed without a major version bump. + fn advance_game(&self, flags: __ws::CallReducerFlags); +} + +impl set_flags_for_advance_game for super::SetReducerFlags { + fn advance_game(&self, flags: __ws::CallReducerFlags) { + self.imp.set_call_reducer_flags("advance_game", flags); + } +} + diff --git a/jong-db/src/db/bot_table.rs b/jong-db/src/db/bot_table.rs index 7c9d250..25f7dfb 100644 --- a/jong-db/src/db/bot_table.rs +++ b/jong-db/src/db/bot_table.rs @@ -2,9 +2,15 @@ // 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, +}; use super::bot_type::Bot; +use super::turn_state_type::TurnState; use super::db_tile_type::DbTile; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `bot`. /// @@ -45,12 +51,8 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> { type Row = Bot; type EventContext = super::EventContext; - fn count(&self) -> u64 { - self.imp.count() - } - fn iter(&self) -> impl Iterator + '_ { - self.imp.iter() - } + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = BotInsertCallbackId; @@ -81,7 +83,8 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("bot"); + + let _table = client_cache.get_or_make_table::("bot"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct BotUpdateCallbackId(__sdk::CallbackId); @@ -101,43 +104,46 @@ impl<'ctx> __sdk::TableWithPrimaryKey for BotTableHandle<'ctx> { } } + #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() }) } -/// Access to the `id` unique index on the table `bot`, -/// which allows point queries on the field of the same name -/// via the [`BotIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.bot().id().find(...)`. -pub struct BotIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> BotTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `bot`. - pub fn id(&self) -> BotIdUnique<'ctx> { - BotIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, + /// Access to the `id` unique index on the table `bot`, + /// which allows point queries on the field of the same name + /// via the [`BotIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.bot().id().find(...)`. + pub struct BotIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } - } -} -impl<'ctx> BotIdUnique<'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) - } -} + impl<'ctx> BotTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `bot`. + pub fn id(&self) -> BotIdUnique<'ctx> { + BotIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> BotIdUnique<'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) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/bot_type.rs b/jong-db/src/db/bot_type.rs index 23ef7d9..b702466 100644 --- a/jong-db/src/db/bot_type.rs +++ b/jong-db/src/db/bot_type.rs @@ -2,8 +2,14 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; +use super::turn_state_type::TurnState; use super::db_tile_type::DbTile; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] @@ -11,11 +17,14 @@ use super::db_tile_type::DbTile; pub struct Bot { pub id: u32, pub lobby_id: u32, - pub hand: Vec, - pub pond: Vec, - pub drawn_tile: Option, + pub turn_state: TurnState, + pub hand: Vec::, + pub pond: Vec::, + pub working_tile: Option::, } + impl __sdk::InModule for Bot { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/clear_all_reducer.rs b/jong-db/src/db/clear_all_reducer.rs index 5870024..f33ae7f 100644 --- a/jong-db/src/db/clear_all_reducer.rs +++ b/jong-db/src/db/clear_all_reducer.rs @@ -2,16 +2,23 @@ // 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}; +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 {} +pub(super) struct ClearAllArgs { + } impl From for super::Reducer { fn from(args: ClearAllArgs) -> Self { Self::ClearAll - } +} } impl __sdk::InModule for ClearAllArgs { @@ -30,7 +37,7 @@ pub trait clear_all { /// 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 by listening for [`Self::on_clear_all`] callbacks. - fn clear_all(&self) -> __sdk::Result<()>; + fn clear_all(&self, ) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `clear_all`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -38,39 +45,34 @@ pub trait clear_all { /// /// The returned [`ClearAllCallbackId`] can be passed to [`Self::remove_on_clear_all`] /// to cancel the callback. - fn on_clear_all( - &self, - callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> ClearAllCallbackId; + fn on_clear_all(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ClearAllCallbackId; /// Cancel a callback previously registered by [`Self::on_clear_all`], /// causing it not to run in the future. fn remove_on_clear_all(&self, callback: ClearAllCallbackId); } impl clear_all for super::RemoteReducers { - fn clear_all(&self) -> __sdk::Result<()> { - self.imp.call_reducer("clear_all", ClearAllArgs {}) + fn clear_all(&self, ) -> __sdk::Result<()> { + self.imp.call_reducer("clear_all", ClearAllArgs { }) } fn on_clear_all( &self, - mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, ) -> ClearAllCallbackId { ClearAllCallbackId(self.imp.on_reducer( "clear_all", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::ClearAll {}, - .. + event: __sdk::ReducerEvent { + reducer: super::Reducer::ClearAll { + }, + .. + }, .. - } = ctx - else { - unreachable!() - }; - callback(ctx) + } = ctx else { unreachable!() }; + callback(ctx, ) }), )) } @@ -98,3 +100,4 @@ impl set_flags_for_clear_all for super::SetReducerFlags { self.imp.set_call_reducer_flags("clear_all", flags); } } + diff --git a/jong-db/src/db/connect_reducer.rs b/jong-db/src/db/connect_reducer.rs new file mode 100644 index 0000000..e82580d --- /dev/null +++ b/jong-db/src/db/connect_reducer.rs @@ -0,0 +1,103 @@ +// 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 ConnectArgs { + } + +impl From for super::Reducer { + fn from(args: ConnectArgs) -> Self { + Self::Connect +} +} + +impl __sdk::InModule for ConnectArgs { + type Module = super::RemoteModule; +} + +pub struct ConnectCallbackId(__sdk::CallbackId); + +#[allow(non_camel_case_types)] +/// Extension trait for access to the reducer `connect`. +/// +/// Implemented for [`super::RemoteReducers`]. +pub trait connect { + /// Request that the remote module invoke the reducer `connect` 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 its status can be observed by listening for [`Self::on_connect`] callbacks. + fn connect(&self, ) -> __sdk::Result<()>; + /// Register a callback to run whenever we are notified of an invocation of the reducer `connect`. + /// + /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] + /// to determine the reducer's status. + /// + /// The returned [`ConnectCallbackId`] can be passed to [`Self::remove_on_connect`] + /// to cancel the callback. + fn on_connect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ConnectCallbackId; + /// Cancel a callback previously registered by [`Self::on_connect`], + /// causing it not to run in the future. + fn remove_on_connect(&self, callback: ConnectCallbackId); +} + +impl connect for super::RemoteReducers { + fn connect(&self, ) -> __sdk::Result<()> { + self.imp.call_reducer("connect", ConnectArgs { }) + } + fn on_connect( + &self, + mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, + ) -> ConnectCallbackId { + ConnectCallbackId(self.imp.on_reducer( + "connect", + Box::new(move |ctx: &super::ReducerEventContext| { + #[allow(irrefutable_let_patterns)] + let super::ReducerEventContext { + event: __sdk::ReducerEvent { + reducer: super::Reducer::Connect { + + }, + .. + }, + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), + )) + } + fn remove_on_connect(&self, callback: ConnectCallbackId) { + self.imp.remove_on_reducer("connect", callback.0) + } +} + +#[allow(non_camel_case_types)] +#[doc(hidden)] +/// Extension trait for setting the call-flags for the reducer `connect`. +/// +/// Implemented for [`super::SetReducerFlags`]. +/// +/// This type is currently unstable and may be removed without a major version bump. +pub trait set_flags_for_connect { + /// Set the call-reducer flags for the reducer `connect` to `flags`. + /// + /// This type is currently unstable and may be removed without a major version bump. + fn connect(&self, flags: __ws::CallReducerFlags); +} + +impl set_flags_for_connect for super::SetReducerFlags { + fn connect(&self, flags: __ws::CallReducerFlags) { + self.imp.set_call_reducer_flags("connect", flags); + } +} + diff --git a/jong-db/src/db/db_tile_type.rs b/jong-db/src/db/db_tile_type.rs index cf5c736..94cb0a9 100644 --- a/jong-db/src/db/db_tile_type.rs +++ b/jong-db/src/db/db_tile_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; use super::tile_type::Tile; @@ -13,6 +18,8 @@ pub struct DbTile { pub tile: Tile, } + impl __sdk::InModule for DbTile { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/db_wall_type.rs b/jong-db/src/db/db_wall_type.rs index 20688c7..7bb7ba5 100644 --- a/jong-db/src/db/db_wall_type.rs +++ b/jong-db/src/db/db_wall_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; use super::db_tile_type::DbTile; @@ -10,9 +15,11 @@ use super::db_tile_type::DbTile; #[sats(crate = __lib)] pub struct DbWall { pub lobby_id: u32, - pub tiles: Vec, + pub tiles: Vec::, } + impl __sdk::InModule for DbWall { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/discard_tile_reducer.rs b/jong-db/src/db/discard_tile_reducer.rs index c3bcb15..204877f 100644 --- a/jong-db/src/db/discard_tile_reducer.rs +++ b/jong-db/src/db/discard_tile_reducer.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -14,8 +20,8 @@ impl From for super::Reducer { fn from(args: DiscardTileArgs) -> Self { Self::DiscardTile { tile_id: args.tile_id, - } - } +} +} } impl __sdk::InModule for DiscardTileArgs { @@ -34,7 +40,8 @@ pub trait discard_tile { /// 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 by listening for [`Self::on_discard_tile`] callbacks. - fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()>; + fn discard_tile(&self, tile_id: u32, +) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `discard_tile`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -42,40 +49,35 @@ pub trait discard_tile { /// /// The returned [`DiscardTileCallbackId`] can be passed to [`Self::remove_on_discard_tile`] /// to cancel the callback. - fn on_discard_tile( - &self, - callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, - ) -> DiscardTileCallbackId; + fn on_discard_tile(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> DiscardTileCallbackId; /// Cancel a callback previously registered by [`Self::on_discard_tile`], /// causing it not to run in the future. fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId); } impl discard_tile for super::RemoteReducers { - fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()> { - self.imp - .call_reducer("discard_tile", DiscardTileArgs { tile_id }) + fn discard_tile(&self, tile_id: u32, +) -> __sdk::Result<()> { + self.imp.call_reducer("discard_tile", DiscardTileArgs { tile_id, }) } fn on_discard_tile( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, ) -> DiscardTileCallbackId { DiscardTileCallbackId(self.imp.on_reducer( "discard_tile", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::DiscardTile { tile_id }, - .. + event: __sdk::ReducerEvent { + reducer: super::Reducer::DiscardTile { + tile_id, }, + .. + }, .. - } = ctx - else { - unreachable!() - }; - callback(ctx, tile_id) + } = ctx else { unreachable!() }; + callback(ctx, tile_id, ) }), )) } @@ -103,3 +105,4 @@ impl set_flags_for_discard_tile for super::SetReducerFlags { self.imp.set_call_reducer_flags("discard_tile", flags); } } + diff --git a/jong-db/src/db/disconnect_reducer.rs b/jong-db/src/db/disconnect_reducer.rs new file mode 100644 index 0000000..795b9ec --- /dev/null +++ b/jong-db/src/db/disconnect_reducer.rs @@ -0,0 +1,103 @@ +// 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 DisconnectArgs { + } + +impl From for super::Reducer { + fn from(args: DisconnectArgs) -> Self { + Self::Disconnect +} +} + +impl __sdk::InModule for DisconnectArgs { + type Module = super::RemoteModule; +} + +pub struct DisconnectCallbackId(__sdk::CallbackId); + +#[allow(non_camel_case_types)] +/// Extension trait for access to the reducer `disconnect`. +/// +/// Implemented for [`super::RemoteReducers`]. +pub trait disconnect { + /// Request that the remote module invoke the reducer `disconnect` 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 its status can be observed by listening for [`Self::on_disconnect`] callbacks. + fn disconnect(&self, ) -> __sdk::Result<()>; + /// Register a callback to run whenever we are notified of an invocation of the reducer `disconnect`. + /// + /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] + /// to determine the reducer's status. + /// + /// The returned [`DisconnectCallbackId`] can be passed to [`Self::remove_on_disconnect`] + /// to cancel the callback. + fn on_disconnect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> DisconnectCallbackId; + /// Cancel a callback previously registered by [`Self::on_disconnect`], + /// causing it not to run in the future. + fn remove_on_disconnect(&self, callback: DisconnectCallbackId); +} + +impl disconnect for super::RemoteReducers { + fn disconnect(&self, ) -> __sdk::Result<()> { + self.imp.call_reducer("disconnect", DisconnectArgs { }) + } + fn on_disconnect( + &self, + mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, + ) -> DisconnectCallbackId { + DisconnectCallbackId(self.imp.on_reducer( + "disconnect", + Box::new(move |ctx: &super::ReducerEventContext| { + #[allow(irrefutable_let_patterns)] + let super::ReducerEventContext { + event: __sdk::ReducerEvent { + reducer: super::Reducer::Disconnect { + + }, + .. + }, + .. + } = ctx else { unreachable!() }; + callback(ctx, ) + }), + )) + } + fn remove_on_disconnect(&self, callback: DisconnectCallbackId) { + self.imp.remove_on_reducer("disconnect", callback.0) + } +} + +#[allow(non_camel_case_types)] +#[doc(hidden)] +/// Extension trait for setting the call-flags for the reducer `disconnect`. +/// +/// Implemented for [`super::SetReducerFlags`]. +/// +/// This type is currently unstable and may be removed without a major version bump. +pub trait set_flags_for_disconnect { + /// Set the call-reducer flags for the reducer `disconnect` to `flags`. + /// + /// This type is currently unstable and may be removed without a major version bump. + fn disconnect(&self, flags: __ws::CallReducerFlags); +} + +impl set_flags_for_disconnect for super::SetReducerFlags { + fn disconnect(&self, flags: __ws::CallReducerFlags) { + self.imp.set_call_reducer_flags("disconnect", flags); + } +} + diff --git a/jong-db/src/db/dragon_type.rs b/jong-db/src/db/dragon_type.rs index 4b954b1..58733f5 100644 --- a/jong-db/src/db/dragon_type.rs +++ b/jong-db/src/db/dragon_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -13,8 +18,12 @@ pub enum Dragon { Hatsu, Chun, + } + + impl __sdk::InModule for Dragon { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/game_state_type.rs b/jong-db/src/db/game_state_type.rs index b8cafa4..7bb60cb 100644 --- a/jong-db/src/db/game_state_type.rs +++ b/jong-db/src/db/game_state_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -19,8 +24,12 @@ pub enum GameState { Play, Exit, + } + + impl __sdk::InModule for GameState { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/game_timer_table.rs b/jong-db/src/db/game_timer_table.rs new file mode 100644 index 0000000..db3138b --- /dev/null +++ b/jong-db/src/db/game_timer_table.rs @@ -0,0 +1,178 @@ +// 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, +}; +use super::game_timer_type::GameTimer; + +/// Table handle for the table `game_timer`. +/// +/// Obtain a handle from the [`GameTimerTableAccess::game_timer`] method on [`super::RemoteTables`], +/// like `ctx.db.game_timer()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.game_timer().on_insert(...)`. +pub struct GameTimerTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `game_timer`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait GameTimerTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`GameTimerTableHandle`], which mediates access to the table `game_timer`. + fn game_timer(&self) -> GameTimerTableHandle<'_>; +} + +impl GameTimerTableAccess for super::RemoteTables { + fn game_timer(&self) -> GameTimerTableHandle<'_> { + GameTimerTableHandle { + imp: self.imp.get_table::("game_timer"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct GameTimerInsertCallbackId(__sdk::CallbackId); +pub struct GameTimerDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> { + type Row = GameTimer; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + + type InsertCallbackId = GameTimerInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> GameTimerInsertCallbackId { + GameTimerInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: GameTimerInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = GameTimerDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> GameTimerDeleteCallbackId { + GameTimerDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: GameTimerDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[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); + _table.add_unique_constraint::("lobby_id", |row| &row.lobby_id); +} +pub struct GameTimerUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> { + type UpdateCallbackId = GameTimerUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> GameTimerUpdateCallbackId { + GameTimerUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: GameTimerUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() + }) +} + + /// 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. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.game_timer().lobby_id().find(...)`. + pub struct GameTimerLobbyIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> GameTimerTableHandle<'ctx> { + /// Get a handle on the `lobby_id` unique index on the table `game_timer`. + pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> { + GameTimerLobbyIdUnique { + imp: self.imp.get_unique_constraint::("lobby_id"), + phantom: std::marker::PhantomData, + } + } + } + + 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 { + self.imp.find(col_val) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/game_timer_type.rs b/jong-db/src/db/game_timer_type.rs new file mode 100644 index 0000000..19af105 --- /dev/null +++ b/jong-db/src/db/game_timer_type.rs @@ -0,0 +1,25 @@ +// 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; +} + diff --git a/jong-db/src/db/join_or_create_lobby_reducer.rs b/jong-db/src/db/join_or_create_lobby_reducer.rs index 2545903..c9aec78 100644 --- a/jong-db/src/db/join_or_create_lobby_reducer.rs +++ b/jong-db/src/db/join_or_create_lobby_reducer.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -14,8 +20,8 @@ impl From for super::Reducer { fn from(args: JoinOrCreateLobbyArgs) -> Self { Self::JoinOrCreateLobby { lobby_id: args.lobby_id, - } - } +} +} } impl __sdk::InModule for JoinOrCreateLobbyArgs { @@ -34,7 +40,8 @@ pub trait join_or_create_lobby { /// 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 by listening for [`Self::on_join_or_create_lobby`] callbacks. - fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()>; + fn join_or_create_lobby(&self, lobby_id: u32, +) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -42,46 +49,40 @@ pub trait join_or_create_lobby { /// /// The returned [`JoinOrCreateLobbyCallbackId`] can be passed to [`Self::remove_on_join_or_create_lobby`] /// to cancel the callback. - fn on_join_or_create_lobby( - &self, - callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, - ) -> JoinOrCreateLobbyCallbackId; + fn on_join_or_create_lobby(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> JoinOrCreateLobbyCallbackId; /// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`], /// causing it not to run in the future. fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId); } impl join_or_create_lobby for super::RemoteReducers { - fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> { - self.imp - .call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id }) + fn join_or_create_lobby(&self, lobby_id: u32, +) -> __sdk::Result<()> { + self.imp.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id, }) } fn on_join_or_create_lobby( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, ) -> JoinOrCreateLobbyCallbackId { JoinOrCreateLobbyCallbackId(self.imp.on_reducer( "join_or_create_lobby", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::JoinOrCreateLobby { lobby_id }, - .. + event: __sdk::ReducerEvent { + reducer: super::Reducer::JoinOrCreateLobby { + lobby_id, }, + .. + }, .. - } = ctx - else { - unreachable!() - }; - callback(ctx, lobby_id) + } = ctx else { unreachable!() }; + callback(ctx, lobby_id, ) }), )) } fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) { - self.imp - .remove_on_reducer("join_or_create_lobby", callback.0) + self.imp.remove_on_reducer("join_or_create_lobby", callback.0) } } @@ -101,7 +102,7 @@ pub trait set_flags_for_join_or_create_lobby { impl set_flags_for_join_or_create_lobby for super::SetReducerFlags { fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags) { - self.imp - .set_call_reducer_flags("join_or_create_lobby", flags); + self.imp.set_call_reducer_flags("join_or_create_lobby", flags); } } + diff --git a/jong-db/src/db/lobby_table.rs b/jong-db/src/db/lobby_table.rs index 98b9f62..e403a30 100644 --- a/jong-db/src/db/lobby_table.rs +++ b/jong-db/src/db/lobby_table.rs @@ -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 + '_ { - self.imp.iter() - } + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { 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) { - let _table = client_cache.get_or_make_table::("lobby"); + + let _table = client_cache.get_or_make_table::("lobby"); _table.add_unique_constraint::("id", |row| &row.id); - _table.add_unique_constraint::("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> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() + __sdk::InternalError::failed_parse( + "TableUpdate", + "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, - 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::("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, + 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 { - 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, - 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::("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::("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 { - 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 { + self.imp.find(col_val) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/lobby_type.rs b/jong-db/src/db/lobby_type.rs index a295a91..34621a1 100644 --- a/jong-db/src/db/lobby_type.rs +++ b/jong-db/src/db/lobby_type.rs @@ -2,24 +2,28 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; -use super::game_state_type::GameState; use super::player_or_bot_type::PlayerOrBot; -use super::turn_state_type::TurnState; +use super::game_state_type::GameState; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct Lobby { pub id: u32, - pub host_player_id: u32, - pub players: Vec, + pub players: Vec::, pub dealer_idx: u8, pub current_idx: u8, pub game_state: GameState, - pub turn_state: TurnState, } + impl __sdk::InModule for Lobby { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/logged_out_player_table.rs b/jong-db/src/db/logged_out_player_table.rs new file mode 100644 index 0000000..a66b89e --- /dev/null +++ b/jong-db/src/db/logged_out_player_table.rs @@ -0,0 +1,178 @@ +// 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, +}; +use super::player_type::Player; + +/// Table handle for the table `logged_out_player`. +/// +/// Obtain a handle from the [`LoggedOutPlayerTableAccess::logged_out_player`] method on [`super::RemoteTables`], +/// like `ctx.db.logged_out_player()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.logged_out_player().on_insert(...)`. +pub struct LoggedOutPlayerTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `logged_out_player`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait LoggedOutPlayerTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`LoggedOutPlayerTableHandle`], which mediates access to the table `logged_out_player`. + fn logged_out_player(&self) -> LoggedOutPlayerTableHandle<'_>; +} + +impl LoggedOutPlayerTableAccess for super::RemoteTables { + fn logged_out_player(&self) -> LoggedOutPlayerTableHandle<'_> { + LoggedOutPlayerTableHandle { + imp: self.imp.get_table::("logged_out_player"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct LoggedOutPlayerInsertCallbackId(__sdk::CallbackId); +pub struct LoggedOutPlayerDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for LoggedOutPlayerTableHandle<'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 = LoggedOutPlayerInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> LoggedOutPlayerInsertCallbackId { + LoggedOutPlayerInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: LoggedOutPlayerInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = LoggedOutPlayerDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> LoggedOutPlayerDeleteCallbackId { + LoggedOutPlayerDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: LoggedOutPlayerDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("logged_out_player"); + _table.add_unique_constraint::("id", |row| &row.id); + _table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity); +} +pub struct LoggedOutPlayerUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for LoggedOutPlayerTableHandle<'ctx> { + type UpdateCallbackId = LoggedOutPlayerUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> LoggedOutPlayerUpdateCallbackId { + LoggedOutPlayerUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: LoggedOutPlayerUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() + }) +} + + /// Access to the `id` unique index on the table `logged_out_player`, + /// which allows point queries on the field of the same name + /// via the [`LoggedOutPlayerIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.logged_out_player().id().find(...)`. + pub struct LoggedOutPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `logged_out_player`. + pub fn id(&self) -> LoggedOutPlayerIdUnique<'ctx> { + LoggedOutPlayerIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> LoggedOutPlayerIdUnique<'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 `logged_out_player`, + /// which allows point queries on the field of the same name + /// via the [`LoggedOutPlayerIdentityUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.logged_out_player().identity().find(...)`. + pub struct LoggedOutPlayerIdentityUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { + /// Get a handle on the `identity` unique index on the table `logged_out_player`. + pub fn identity(&self) -> LoggedOutPlayerIdentityUnique<'ctx> { + LoggedOutPlayerIdentityUnique { + imp: self.imp.get_unique_constraint::<__sdk::Identity>("identity"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> LoggedOutPlayerIdentityUnique<'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) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/mod.rs b/jong-db/src/db/mod.rs index 3eb7040..4d46508 100644 --- a/jong-db/src/db/mod.rs +++ b/jong-db/src/db/mod.rs @@ -4,73 +4,80 @@ // This was generated using spacetimedb cli version 1.11.3 (commit 02449737ca3b29e7e39679fccbef541a50f32094). #![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; -pub mod add_bot_reducer; -pub mod advance_state_timer_table; -pub mod advance_state_timer_type; -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 draw_tile_reducer; pub mod game_state_type; -pub mod join_or_create_lobby_reducer; -pub mod lobby_table; +pub mod game_timer_type; pub mod lobby_type; -pub mod login_or_add_player_reducer; -pub mod player_or_bot_type; -pub mod player_table; pub mod player_type; +pub mod player_clock_type; +pub mod player_hand_type; +pub mod player_or_bot_type; pub mod rank_type; -pub mod set_ready_reducer; -pub mod shuffle_deal_reducer; -pub mod skip_call_reducer; -pub mod start_game_reducer; pub mod suit_type; -pub mod tile_table; pub mod tile_type; pub mod turn_state_type; -pub mod wall_table; pub mod wind_type; +pub mod add_bot_reducer; +pub mod advance_game_reducer; +pub mod clear_all_reducer; +pub mod connect_reducer; +pub mod discard_tile_reducer; +pub mod disconnect_reducer; +pub mod join_or_create_lobby_reducer; +pub mod set_ready_reducer; +pub mod bot_table; +pub mod game_timer_table; +pub mod lobby_table; +pub mod logged_out_player_table; +pub mod player_table; +pub mod player_clock_table; +pub mod player_hand_table; +pub mod tile_table; +pub mod wall_table; -pub use add_bot_reducer::{add_bot, set_flags_for_add_bot, AddBotCallbackId}; -pub use advance_state_timer_table::*; -pub use advance_state_timer_type::AdvanceStateTimer; -pub use bot_table::*; pub use bot_type::Bot; -pub use clear_all_reducer::{clear_all, set_flags_for_clear_all, ClearAllCallbackId}; pub use db_tile_type::DbTile; pub use db_wall_type::DbWall; -pub use discard_tile_reducer::{discard_tile, set_flags_for_discard_tile, DiscardTileCallbackId}; pub use dragon_type::Dragon; -pub use draw_tile_reducer::{draw_tile, set_flags_for_draw_tile, DrawTileCallbackId}; pub use game_state_type::GameState; -pub use join_or_create_lobby_reducer::{ - join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId, -}; -pub use lobby_table::*; +pub use game_timer_type::GameTimer; pub use lobby_type::Lobby; -pub use login_or_add_player_reducer::{ - login_or_add_player, set_flags_for_login_or_add_player, LoginOrAddPlayerCallbackId, -}; -pub use player_or_bot_type::PlayerOrBot; -pub use player_table::*; pub use player_type::Player; +pub use player_clock_type::PlayerClock; +pub use player_hand_type::PlayerHand; +pub use player_or_bot_type::PlayerOrBot; pub use rank_type::Rank; -pub use set_ready_reducer::{set_flags_for_set_ready, set_ready, SetReadyCallbackId}; -pub use shuffle_deal_reducer::{set_flags_for_shuffle_deal, shuffle_deal, ShuffleDealCallbackId}; -pub use skip_call_reducer::{set_flags_for_skip_call, skip_call, SkipCallCallbackId}; -pub use start_game_reducer::{set_flags_for_start_game, start_game, StartGameCallbackId}; pub use suit_type::Suit; -pub use tile_table::*; pub use tile_type::Tile; pub use turn_state_type::TurnState; -pub use wall_table::*; pub use wind_type::Wind; +pub use bot_table::*; +pub use game_timer_table::*; +pub use lobby_table::*; +pub use logged_out_player_table::*; +pub use player_table::*; +pub use player_clock_table::*; +pub use player_hand_table::*; +pub use tile_table::*; +pub use wall_table::*; +pub use add_bot_reducer::{add_bot, set_flags_for_add_bot, AddBotCallbackId}; +pub use advance_game_reducer::{advance_game, set_flags_for_advance_game, AdvanceGameCallbackId}; +pub use clear_all_reducer::{clear_all, set_flags_for_clear_all, ClearAllCallbackId}; +pub use connect_reducer::{connect, set_flags_for_connect, ConnectCallbackId}; +pub use discard_tile_reducer::{discard_tile, set_flags_for_discard_tile, DiscardTileCallbackId}; +pub use disconnect_reducer::{disconnect, set_flags_for_disconnect, DisconnectCallbackId}; +pub use join_or_create_lobby_reducer::{join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId}; +pub use set_ready_reducer::{set_ready, set_flags_for_set_ready, SetReadyCallbackId}; #[derive(Clone, PartialEq, Debug)] @@ -80,18 +87,27 @@ pub use wind_type::Wind; /// to indicate which reducer caused the event. pub enum Reducer { - AddBot { lobby_id: u32 }, - ClearAll, - DiscardTile { tile_id: u32 }, - DrawTile, - JoinOrCreateLobby { lobby_id: u32 }, - LoginOrAddPlayer, - SetReady { ready: bool }, - ShuffleDeal { lobby_id: u32 }, - SkipCall, - StartGame, + AddBot { + lobby_id: u32, +} , + AdvanceGame { + game_timer: GameTimer, +} , + ClearAll , + Connect , + DiscardTile { + tile_id: u32, +} , + Disconnect , + JoinOrCreateLobby { + lobby_id: u32, +} , + SetReady { + ready: bool, +} , } + impl __sdk::InModule for Reducer { type Module = RemoteModule; } @@ -99,140 +115,74 @@ impl __sdk::InModule for Reducer { impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::AddBot { .. } => "add_bot", + Reducer::AddBot { .. } => "add_bot", + Reducer::AdvanceGame { .. } => "advance_game", Reducer::ClearAll => "clear_all", + Reducer::Connect => "connect", Reducer::DiscardTile { .. } => "discard_tile", - Reducer::DrawTile => "draw_tile", + Reducer::Disconnect => "disconnect", Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby", - Reducer::LoginOrAddPlayer => "login_or_add_player", Reducer::SetReady { .. } => "set_ready", - Reducer::ShuffleDeal { .. } => "shuffle_deal", - Reducer::SkipCall => "skip_call", - Reducer::StartGame => "start_game", _ => unreachable!(), - } - } +} +} } impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { - type Error = __sdk::Error; - fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result { + type Error = __sdk::Error; +fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result { match &value.reducer_name[..] { - "add_bot" => Ok(__sdk::parse_reducer_args::( - "add_bot", - &value.args, - )? - .into()), - "clear_all" => Ok( - __sdk::parse_reducer_args::( - "clear_all", - &value.args, - )? - .into(), - ), - "discard_tile" => Ok( - __sdk::parse_reducer_args::( - "discard_tile", - &value.args, - )? - .into(), - ), - "draw_tile" => Ok( - __sdk::parse_reducer_args::( - "draw_tile", - &value.args, - )? - .into(), - ), - "join_or_create_lobby" => Ok(__sdk::parse_reducer_args::< - join_or_create_lobby_reducer::JoinOrCreateLobbyArgs, - >("join_or_create_lobby", &value.args)? - .into()), - "login_or_add_player" => Ok(__sdk::parse_reducer_args::< - login_or_add_player_reducer::LoginOrAddPlayerArgs, - >("login_or_add_player", &value.args)? - .into()), - "set_ready" => Ok( - __sdk::parse_reducer_args::( - "set_ready", - &value.args, - )? - .into(), - ), - "shuffle_deal" => Ok( - __sdk::parse_reducer_args::( - "shuffle_deal", - &value.args, - )? - .into(), - ), - "skip_call" => Ok( - __sdk::parse_reducer_args::( - "skip_call", - &value.args, - )? - .into(), - ), - "start_game" => Ok( - __sdk::parse_reducer_args::( - "start_game", - &value.args, - )? - .into(), - ), - unknown => { - Err( - __sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo") - .into(), - ) - } - } - } + "add_bot" => Ok(__sdk::parse_reducer_args::("add_bot", &value.args)?.into()), + "advance_game" => Ok(__sdk::parse_reducer_args::("advance_game", &value.args)?.into()), + "clear_all" => Ok(__sdk::parse_reducer_args::("clear_all", &value.args)?.into()), + "connect" => Ok(__sdk::parse_reducer_args::("connect", &value.args)?.into()), + "discard_tile" => Ok(__sdk::parse_reducer_args::("discard_tile", &value.args)?.into()), + "disconnect" => Ok(__sdk::parse_reducer_args::("disconnect", &value.args)?.into()), + "join_or_create_lobby" => Ok(__sdk::parse_reducer_args::("join_or_create_lobby", &value.args)?.into()), + "set_ready" => Ok(__sdk::parse_reducer_args::("set_ready", &value.args)?.into()), + unknown => Err(__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo").into()), +} +} } #[derive(Default)] #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - advance_state_timer: __sdk::TableUpdate, - bot: __sdk::TableUpdate, + bot: __sdk::TableUpdate, + game_timer: __sdk::TableUpdate, lobby: __sdk::TableUpdate, + logged_out_player: __sdk::TableUpdate, player: __sdk::TableUpdate, + player_clock: __sdk::TableUpdate, + player_hand: __sdk::TableUpdate, tile: __sdk::TableUpdate, wall: __sdk::TableUpdate, } + impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { type Error = __sdk::Error; fn try_from(raw: __ws::DatabaseUpdate<__ws::BsatnFormat>) -> Result { let mut db_update = DbUpdate::default(); for table_update in raw.tables { match &table_update.table_name[..] { - "advance_state_timer" => db_update - .advance_state_timer - .append(advance_state_timer_table::parse_table_update(table_update)?), - "bot" => db_update - .bot - .append(bot_table::parse_table_update(table_update)?), - "lobby" => db_update - .lobby - .append(lobby_table::parse_table_update(table_update)?), - "player" => db_update - .player - .append(player_table::parse_table_update(table_update)?), - "tile" => db_update - .tile - .append(tile_table::parse_table_update(table_update)?), - "wall" => db_update - .wall - .append(wall_table::parse_table_update(table_update)?), + + "bot" => db_update.bot.append(bot_table::parse_table_update(table_update)?), + "game_timer" => db_update.game_timer.append(game_timer_table::parse_table_update(table_update)?), + "lobby" => db_update.lobby.append(lobby_table::parse_table_update(table_update)?), + "logged_out_player" => db_update.logged_out_player.append(logged_out_player_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_hand" => db_update.player_hand.append(player_hand_table::parse_table_update(table_update)?), + "tile" => db_update.tile.append(tile_table::parse_table_update(table_update)?), + "wall" => db_update.wall.append(wall_table::parse_table_update(table_update)?), unknown => { return Err(__sdk::InternalError::unknown_name( "table", unknown, "DatabaseUpdate", - ) - .into()); + ).into()); } } } @@ -245,73 +195,58 @@ impl __sdk::InModule for DbUpdate { } impl __sdk::DbUpdate for DbUpdate { - fn apply_to_client_cache( - &self, - cache: &mut __sdk::ClientCache, - ) -> AppliedDiff<'_> { - let mut diff = AppliedDiff::default(); + fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) -> AppliedDiff<'_> { + let mut diff = AppliedDiff::default(); + + diff.bot = cache.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); + diff.lobby = cache.apply_diff_to_table::("lobby", &self.lobby).with_updates_by_pk(|row| &row.id); + diff.logged_out_player = cache.apply_diff_to_table::("logged_out_player", &self.logged_out_player).with_updates_by_pk(|row| &row.identity); + 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.id); + diff.player_hand = cache.apply_diff_to_table::("player_hand", &self.player_hand).with_updates_by_pk(|row| &row.id); + diff.tile = cache.apply_diff_to_table::("tile", &self.tile).with_updates_by_pk(|row| &row.id); + diff.wall = cache.apply_diff_to_table::("wall", &self.wall).with_updates_by_pk(|row| &row.lobby_id); - diff.advance_state_timer = cache - .apply_diff_to_table::( - "advance_state_timer", - &self.advance_state_timer, - ) - .with_updates_by_pk(|row| &row.scheduled_id); - diff.bot = cache - .apply_diff_to_table::("bot", &self.bot) - .with_updates_by_pk(|row| &row.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.tile = cache - .apply_diff_to_table::("tile", &self.tile) - .with_updates_by_pk(|row| &row.id); - diff.wall = cache - .apply_diff_to_table::("wall", &self.wall) - .with_updates_by_pk(|row| &row.lobby_id); - - diff - } + diff + } } #[derive(Default)] #[allow(non_snake_case)] #[doc(hidden)] pub struct AppliedDiff<'r> { - advance_state_timer: __sdk::TableAppliedDiff<'r, AdvanceStateTimer>, - bot: __sdk::TableAppliedDiff<'r, Bot>, + bot: __sdk::TableAppliedDiff<'r, Bot>, + game_timer: __sdk::TableAppliedDiff<'r, GameTimer>, lobby: __sdk::TableAppliedDiff<'r, Lobby>, + logged_out_player: __sdk::TableAppliedDiff<'r, Player>, player: __sdk::TableAppliedDiff<'r, Player>, + player_clock: __sdk::TableAppliedDiff<'r, PlayerClock>, + player_hand: __sdk::TableAppliedDiff<'r, PlayerHand>, tile: __sdk::TableAppliedDiff<'r, DbTile>, wall: __sdk::TableAppliedDiff<'r, DbWall>, __unused: std::marker::PhantomData<&'r ()>, } + impl __sdk::InModule for AppliedDiff<'_> { type Module = RemoteModule; } impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> { - fn invoke_row_callbacks( - &self, - event: &EventContext, - callbacks: &mut __sdk::DbCallbacks, - ) { - callbacks.invoke_table_row_callbacks::( - "advance_state_timer", - &self.advance_state_timer, - event, - ); - callbacks.invoke_table_row_callbacks::("bot", &self.bot, event); + fn invoke_row_callbacks(&self, event: &EventContext, 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::("lobby", &self.lobby, event); + callbacks.invoke_table_row_callbacks::("logged_out_player", &self.logged_out_player, 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_hand", &self.player_hand, event); callbacks.invoke_table_row_callbacks::("tile", &self.tile, event); callbacks.invoke_table_row_callbacks::("wall", &self.wall, event); - } } +} + #[doc(hidden)] pub struct RemoteModule; @@ -564,6 +499,7 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle { fn unsubscribe(self) -> __sdk::Result<()> { self.imp.unsubscribe_then(None) } + } /// Alias trait for a [`__sdk::DbContext`] connected to this module, @@ -571,25 +507,19 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle { /// /// Users can use this trait as a boundary on definitions which should accept /// either a [`DbConnection`] or an [`EventContext`] and operate on either. -pub trait RemoteDbContext: - __sdk::DbContext< +pub trait RemoteDbContext: __sdk::DbContext< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, SubscriptionBuilder = __sdk::SubscriptionBuilder, -> -{ -} -impl< - Ctx: __sdk::DbContext< - DbView = RemoteTables, - Reducers = RemoteReducers, - SetReducerFlags = SetReducerFlags, - SubscriptionBuilder = __sdk::SubscriptionBuilder, - >, - > RemoteDbContext for Ctx -{ -} +> {} +impl, +>> RemoteDbContext for Ctx {} + /// An [`__sdk::DbContext`] augmented with a [`__sdk::Event`], /// passed to [`__sdk::Table::on_insert`], [`__sdk::Table::on_delete`] and [`__sdk::TableWithPrimaryKey::on_update`] callbacks. @@ -1014,6 +944,7 @@ impl __sdk::DbContext for ErrorContext { impl __sdk::ErrorContext for ErrorContext {} impl __sdk::SpacetimeModule for RemoteModule { + type DbConnection = DbConnection; type EventContext = EventContext; type ReducerEventContext = ReducerEventContext; @@ -1028,12 +959,15 @@ impl __sdk::SpacetimeModule for RemoteModule { type AppliedDiff<'r> = AppliedDiff<'r>; type SubscriptionHandle = SubscriptionHandle; - fn register_tables(client_cache: &mut __sdk::ClientCache) { - advance_state_timer_table::register_table(client_cache); - bot_table::register_table(client_cache); +fn register_tables(client_cache: &mut __sdk::ClientCache) { + bot_table::register_table(client_cache); + game_timer_table::register_table(client_cache); lobby_table::register_table(client_cache); + logged_out_player_table::register_table(client_cache); player_table::register_table(client_cache); + player_clock_table::register_table(client_cache); + player_hand_table::register_table(client_cache); tile_table::register_table(client_cache); wall_table::register_table(client_cache); - } +} } diff --git a/jong-db/src/db/player_clock_table.rs b/jong-db/src/db/player_clock_table.rs new file mode 100644 index 0000000..41dc148 --- /dev/null +++ b/jong-db/src/db/player_clock_table.rs @@ -0,0 +1,178 @@ +// 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, +}; +use super::player_clock_type::PlayerClock; + +/// Table handle for the table `player_clock`. +/// +/// Obtain a handle from the [`PlayerClockTableAccess::player_clock`] method on [`super::RemoteTables`], +/// like `ctx.db.player_clock()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_clock().on_insert(...)`. +pub struct PlayerClockTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `player_clock`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait PlayerClockTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`PlayerClockTableHandle`], which mediates access to the table `player_clock`. + fn player_clock(&self) -> PlayerClockTableHandle<'_>; +} + +impl PlayerClockTableAccess for super::RemoteTables { + fn player_clock(&self) -> PlayerClockTableHandle<'_> { + PlayerClockTableHandle { + imp: self.imp.get_table::("player_clock"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct PlayerClockInsertCallbackId(__sdk::CallbackId); +pub struct PlayerClockDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> { + type Row = PlayerClock; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + + type InsertCallbackId = PlayerClockInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerClockInsertCallbackId { + PlayerClockInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: PlayerClockInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = PlayerClockDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerClockDeleteCallbackId { + PlayerClockDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: PlayerClockDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[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); +} +pub struct PlayerClockUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for PlayerClockTableHandle<'ctx> { + type UpdateCallbackId = PlayerClockUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> PlayerClockUpdateCallbackId { + PlayerClockUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: PlayerClockUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() + }) +} + + /// 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. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.player_clock().player_id().find(...)`. + pub struct PlayerClockPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> PlayerClockTableHandle<'ctx> { + /// Get a handle on the `player_id` unique index on the table `player_clock`. + pub fn player_id(&self) -> PlayerClockPlayerIdUnique<'ctx> { + PlayerClockPlayerIdUnique { + imp: self.imp.get_unique_constraint::("player_id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> PlayerClockPlayerIdUnique<'ctx> { + /// Find the subscribed row whose `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 { + self.imp.find(col_val) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/player_clock_type.rs b/jong-db/src/db/player_clock_type.rs new file mode 100644 index 0000000..6c533e6 --- /dev/null +++ b/jong-db/src/db/player_clock_type.rs @@ -0,0 +1,26 @@ +// 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 PlayerClock { + pub id: u32, + pub player_id: u32, + pub renewable: u16, + pub total: u16, +} + + +impl __sdk::InModule for PlayerClock { + type Module = super::RemoteModule; +} + diff --git a/jong-db/src/db/player_hand_table.rs b/jong-db/src/db/player_hand_table.rs new file mode 100644 index 0000000..609edd8 --- /dev/null +++ b/jong-db/src/db/player_hand_table.rs @@ -0,0 +1,180 @@ +// 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, +}; +use super::player_hand_type::PlayerHand; +use super::turn_state_type::TurnState; +use super::db_tile_type::DbTile; + +/// Table handle for the table `player_hand`. +/// +/// Obtain a handle from the [`PlayerHandTableAccess::player_hand`] method on [`super::RemoteTables`], +/// like `ctx.db.player_hand()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_hand().on_insert(...)`. +pub struct PlayerHandTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `player_hand`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait PlayerHandTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`PlayerHandTableHandle`], which mediates access to the table `player_hand`. + fn player_hand(&self) -> PlayerHandTableHandle<'_>; +} + +impl PlayerHandTableAccess for super::RemoteTables { + fn player_hand(&self) -> PlayerHandTableHandle<'_> { + PlayerHandTableHandle { + imp: self.imp.get_table::("player_hand"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct PlayerHandInsertCallbackId(__sdk::CallbackId); +pub struct PlayerHandDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for PlayerHandTableHandle<'ctx> { + type Row = PlayerHand; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + + type InsertCallbackId = PlayerHandInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerHandInsertCallbackId { + PlayerHandInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: PlayerHandInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = PlayerHandDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerHandDeleteCallbackId { + PlayerHandDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: PlayerHandDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + + let _table = client_cache.get_or_make_table::("player_hand"); + _table.add_unique_constraint::("id", |row| &row.id); + _table.add_unique_constraint::("player_id", |row| &row.player_id); +} +pub struct PlayerHandUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for PlayerHandTableHandle<'ctx> { + type UpdateCallbackId = PlayerHandUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> PlayerHandUpdateCallbackId { + PlayerHandUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: PlayerHandUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() + }) +} + + /// Access to the `id` unique index on the table `player_hand`, + /// which allows point queries on the field of the same name + /// via the [`PlayerHandIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.player_hand().id().find(...)`. + pub struct PlayerHandIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> PlayerHandTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `player_hand`. + pub fn id(&self) -> PlayerHandIdUnique<'ctx> { + PlayerHandIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> PlayerHandIdUnique<'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_hand`, + /// which allows point queries on the field of the same name + /// via the [`PlayerHandPlayerIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.player_hand().player_id().find(...)`. + pub struct PlayerHandPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, + } + + impl<'ctx> PlayerHandTableHandle<'ctx> { + /// Get a handle on the `player_id` unique index on the table `player_hand`. + pub fn player_id(&self) -> PlayerHandPlayerIdUnique<'ctx> { + PlayerHandPlayerIdUnique { + imp: self.imp.get_unique_constraint::("player_id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> PlayerHandPlayerIdUnique<'ctx> { + /// Find the subscribed row whose `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 { + self.imp.find(col_val) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/player_hand_type.rs b/jong-db/src/db/player_hand_type.rs new file mode 100644 index 0000000..7e62fa6 --- /dev/null +++ b/jong-db/src/db/player_hand_type.rs @@ -0,0 +1,30 @@ +// 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, +}; + +use super::turn_state_type::TurnState; +use super::db_tile_type::DbTile; + +#[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 working_tile: Option::, +} + + +impl __sdk::InModule for PlayerHand { + type Module = super::RemoteModule; +} + diff --git a/jong-db/src/db/player_or_bot_type.rs b/jong-db/src/db/player_or_bot_type.rs index 538d940..eb5d35c 100644 --- a/jong-db/src/db/player_or_bot_type.rs +++ b/jong-db/src/db/player_or_bot_type.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -10,8 +16,12 @@ 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 index ee7b127..0aa30cd 100644 --- a/jong-db/src/db/player_table.rs +++ b/jong-db/src/db/player_table.rs @@ -2,9 +2,13 @@ // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. #![allow(unused, clippy::all)] -use super::db_tile_type::DbTile; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; use super::player_type::Player; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `player`. /// @@ -45,12 +49,8 @@ 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() - } + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = PlayerInsertCallbackId; @@ -81,9 +81,10 @@ impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> { #[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::<__sdk::Identity>("identity", |row| &row.identity); + + 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); } pub struct PlayerUpdateCallbackId(__sdk::CallbackId); @@ -102,75 +103,76 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> { } } + #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() }) } -/// 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, + /// 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> 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) - } -} - -/// 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> 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) - } -} + 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) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/player_type.rs b/jong-db/src/db/player_type.rs index 582ca86..4e0df5a 100644 --- a/jong-db/src/db/player_type.rs +++ b/jong-db/src/db/player_type.rs @@ -2,24 +2,27 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; -use super::db_tile_type::DbTile; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] pub struct Player { - pub identity: __sdk::Identity, pub id: u32, - pub name: Option, + pub identity: __sdk::Identity, + pub name: Option::, pub lobby_id: u32, pub ready: bool, pub sort: bool, - pub hand: Vec, - pub pond: Vec, - pub drawn_tile: Option, } + impl __sdk::InModule for Player { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/rank_type.rs b/jong-db/src/db/rank_type.rs index 5b40b70..53c89f3 100644 --- a/jong-db/src/db/rank_type.rs +++ b/jong-db/src/db/rank_type.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -10,6 +16,8 @@ pub struct Rank { pub number: u8, } + impl __sdk::InModule for Rank { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/set_ready_reducer.rs b/jong-db/src/db/set_ready_reducer.rs index bebd7cf..901b840 100644 --- a/jong-db/src/db/set_ready_reducer.rs +++ b/jong-db/src/db/set_ready_reducer.rs @@ -2,7 +2,13 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; + #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -12,8 +18,10 @@ pub(super) struct SetReadyArgs { impl From for super::Reducer { fn from(args: SetReadyArgs) -> Self { - Self::SetReady { ready: args.ready } - } + Self::SetReady { + ready: args.ready, +} +} } impl __sdk::InModule for SetReadyArgs { @@ -32,7 +40,8 @@ pub trait set_ready { /// 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 by listening for [`Self::on_set_ready`] callbacks. - fn set_ready(&self, ready: bool) -> __sdk::Result<()>; + fn set_ready(&self, ready: bool, +) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -40,39 +49,35 @@ pub trait set_ready { /// /// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`] /// to cancel the callback. - fn on_set_ready( - &self, - callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static, - ) -> SetReadyCallbackId; + fn on_set_ready(&self, callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static) -> SetReadyCallbackId; /// Cancel a callback previously registered by [`Self::on_set_ready`], /// causing it not to run in the future. fn remove_on_set_ready(&self, callback: SetReadyCallbackId); } impl set_ready for super::RemoteReducers { - fn set_ready(&self, ready: bool) -> __sdk::Result<()> { - self.imp.call_reducer("set_ready", SetReadyArgs { ready }) + fn set_ready(&self, ready: bool, +) -> __sdk::Result<()> { + self.imp.call_reducer("set_ready", SetReadyArgs { ready, }) } fn on_set_ready( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static, ) -> SetReadyCallbackId { SetReadyCallbackId(self.imp.on_reducer( "set_ready", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::SetReady { ready }, - .. + event: __sdk::ReducerEvent { + reducer: super::Reducer::SetReady { + ready, }, + .. + }, .. - } = ctx - else { - unreachable!() - }; - callback(ctx, ready) + } = ctx else { unreachable!() }; + callback(ctx, ready, ) }), )) } @@ -100,3 +105,4 @@ impl set_flags_for_set_ready for super::SetReducerFlags { self.imp.set_call_reducer_flags("set_ready", flags); } } + diff --git a/jong-db/src/db/suit_type.rs b/jong-db/src/db/suit_type.rs index be17c21..53d5b31 100644 --- a/jong-db/src/db/suit_type.rs +++ b/jong-db/src/db/suit_type.rs @@ -2,11 +2,16 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; -use super::dragon_type::Dragon; use super::rank_type::Rank; use super::wind_type::Wind; +use super::dragon_type::Dragon; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -20,8 +25,12 @@ pub enum Suit { Wind(Wind), Dragon(Dragon), + } + + impl __sdk::InModule for Suit { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/tile_table.rs b/jong-db/src/db/tile_table.rs index 8d188eb..9075ccf 100644 --- a/jong-db/src/db/tile_table.rs +++ b/jong-db/src/db/tile_table.rs @@ -2,9 +2,14 @@ // 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, +}; use super::db_tile_type::DbTile; use super::tile_type::Tile; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `tile`. /// @@ -45,12 +50,8 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> { type Row = DbTile; type EventContext = super::EventContext; - fn count(&self) -> u64 { - self.imp.count() - } - fn iter(&self) -> impl Iterator + '_ { - self.imp.iter() - } + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = TileInsertCallbackId; @@ -81,7 +82,8 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("tile"); + + let _table = client_cache.get_or_make_table::("tile"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct TileUpdateCallbackId(__sdk::CallbackId); @@ -101,43 +103,46 @@ impl<'ctx> __sdk::TableWithPrimaryKey for TileTableHandle<'ctx> { } } + #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() }) } -/// Access to the `id` unique index on the table `tile`, -/// which allows point queries on the field of the same name -/// via the [`TileIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.tile().id().find(...)`. -pub struct TileIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> TileTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `tile`. - pub fn id(&self) -> TileIdUnique<'ctx> { - TileIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, + /// Access to the `id` unique index on the table `tile`, + /// which allows point queries on the field of the same name + /// via the [`TileIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.tile().id().find(...)`. + pub struct TileIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } - } -} -impl<'ctx> TileIdUnique<'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) - } -} + impl<'ctx> TileTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `tile`. + pub fn id(&self) -> TileIdUnique<'ctx> { + TileIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> TileIdUnique<'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) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/tile_type.rs b/jong-db/src/db/tile_type.rs index 64b1919..6c56495 100644 --- a/jong-db/src/db/tile_type.rs +++ b/jong-db/src/db/tile_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; use super::suit_type::Suit; @@ -12,6 +17,8 @@ pub struct Tile { pub suit: Suit, } + impl __sdk::InModule for Tile { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/turn_state_type.rs b/jong-db/src/db/turn_state_type.rs index e09ddbe..681e72c 100644 --- a/jong-db/src/db/turn_state_type.rs +++ b/jong-db/src/db/turn_state_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -19,8 +24,12 @@ pub enum TurnState { RonChiiPonKan, End, + } + + impl __sdk::InModule for TurnState { type Module = super::RemoteModule; } + diff --git a/jong-db/src/db/wall_table.rs b/jong-db/src/db/wall_table.rs index 1f920d6..e9f4d46 100644 --- a/jong-db/src/db/wall_table.rs +++ b/jong-db/src/db/wall_table.rs @@ -2,9 +2,14 @@ // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. #![allow(unused, clippy::all)] -use super::db_tile_type::DbTile; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; use super::db_wall_type::DbWall; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; +use super::db_tile_type::DbTile; /// Table handle for the table `wall`. /// @@ -45,12 +50,8 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> { type Row = DbWall; type EventContext = super::EventContext; - fn count(&self) -> u64 { - self.imp.count() - } - fn iter(&self) -> impl Iterator + '_ { - self.imp.iter() - } + fn count(&self) -> u64 { self.imp.count() } + fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = WallInsertCallbackId; @@ -81,7 +82,8 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("wall"); + + let _table = client_cache.get_or_make_table::("wall"); _table.add_unique_constraint::("lobby_id", |row| &row.lobby_id); } pub struct WallUpdateCallbackId(__sdk::CallbackId); @@ -101,43 +103,46 @@ impl<'ctx> __sdk::TableWithPrimaryKey for WallTableHandle<'ctx> { } } + #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() + __sdk::InternalError::failed_parse( + "TableUpdate", + "TableUpdate", + ).with_cause(e).into() }) } -/// Access to the `lobby_id` unique index on the table `wall`, -/// which allows point queries on the field of the same name -/// via the [`WallLobbyIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.wall().lobby_id().find(...)`. -pub struct WallLobbyIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> WallTableHandle<'ctx> { - /// Get a handle on the `lobby_id` unique index on the table `wall`. - pub fn lobby_id(&self) -> WallLobbyIdUnique<'ctx> { - WallLobbyIdUnique { - imp: self.imp.get_unique_constraint::("lobby_id"), - phantom: std::marker::PhantomData, + /// Access to the `lobby_id` unique index on the table `wall`, + /// which allows point queries on the field of the same name + /// via the [`WallLobbyIdUnique::find`] method. + /// + /// Users are encouraged not to explicitly reference this type, + /// but to directly chain method calls, + /// like `ctx.db.wall().lobby_id().find(...)`. + pub struct WallLobbyIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } - } -} -impl<'ctx> WallLobbyIdUnique<'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 { - self.imp.find(col_val) - } -} + impl<'ctx> WallTableHandle<'ctx> { + /// Get a handle on the `lobby_id` unique index on the table `wall`. + pub fn lobby_id(&self) -> WallLobbyIdUnique<'ctx> { + WallLobbyIdUnique { + imp: self.imp.get_unique_constraint::("lobby_id"), + phantom: std::marker::PhantomData, + } + } + } + + impl<'ctx> WallLobbyIdUnique<'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 { + self.imp.find(col_val) + } + } + \ No newline at end of file diff --git a/jong-db/src/db/wind_type.rs b/jong-db/src/db/wind_type.rs index a1c3965..8f9800c 100644 --- a/jong-db/src/db/wind_type.rs +++ b/jong-db/src/db/wind_type.rs @@ -2,7 +2,12 @@ // 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}; +use spacetimedb_sdk::__codegen::{ + self as __sdk, + __lib, + __sats, + __ws, +}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -15,8 +20,12 @@ pub enum Wind { Shaa, Pei, + } + + impl __sdk::InModule for Wind { type Module = super::RemoteModule; } + diff --git a/jong-line/src/lib.rs b/jong-line/src/lib.rs index 28bf92a..adcca63 100644 --- a/jong-line/src/lib.rs +++ b/jong-line/src/lib.rs @@ -1,15 +1,9 @@ use log::debug; use spacetimedb::{ReducerContext, Table, reducer}; -use jong_types::TurnState; - use crate::tables::*; -mod reducers { - mod deal; - mod hand; - mod lobby; -} +mod reducers; mod tables; #[reducer] @@ -32,27 +26,40 @@ pub fn clear_all(ctx: &ReducerContext) { } #[reducer(client_connected)] -pub fn login_or_add_player(ctx: &ReducerContext) { - let identity = ctx.sender; - - // TODO remove player on disconnect - if let Ok(player) = ctx.db.player().try_insert(Player { - identity, - id: 0, - name: None, - lobby_id: 0, - ready: false, - sort: true, - hand: vec![], - pond: vec![], - drawn_tile: None, - turn_state: TurnState::None, - }) { - debug!("added player: {:?}", player); +pub fn connect(ctx: &ReducerContext) -> Result<(), String> { + let player = if let Some(player) = ctx.db.logged_out_player().identity().find(ctx.sender) { + let player = ctx.db.player().insert(player); + ctx.db.logged_out_player().identity().delete(ctx.sender); + player } else { - let player = ctx.db.player().identity().find(identity).unwrap(); - debug!("player {:?} has reconnected", player) - } + ctx.db.player().try_insert(Player { + identity: ctx.sender, + id: 0, + name: None, + lobby_id: 0, + ready: false, + sort: true, + })? + }; + + debug!("player connected: {:?}", player); + + Ok(()) +} + +#[reducer(client_disconnected)] +pub fn disconnect(ctx: &ReducerContext) -> Result<(), String> { + let player = ctx + .db + .player() + .identity() + .find(ctx.sender) + .ok_or_else(|| format!("can't find player {}", ctx.sender))?; + + ctx.db.logged_out_player().insert(player); + ctx.db.player().identity().delete(ctx.sender); + + Ok(()) } // #[reducer(init)] @@ -65,11 +72,6 @@ pub fn login_or_add_player(ctx: &ReducerContext) { // // Called everytime a new client connects // } -// #[reducer(client_disconnected)] -// pub fn identity_disconnected(_ctx: &ReducerContext) { -// // Called everytime a client disconnects -// } - // #[reducer] // pub fn add(ctx: &ReducerContext, name: String) { // ctx.db.player().insert(Player { name }); diff --git a/jong-line/src/reducers.rs b/jong-line/src/reducers.rs new file mode 100644 index 0000000..a9ce012 --- /dev/null +++ b/jong-line/src/reducers.rs @@ -0,0 +1,118 @@ +use std::time::Duration; + +use spacetimedb::{ReducerContext, ScheduleAt::Interval, reducer}; + +use jong_types::{GameState, TurnState}; + +use crate::{ + reducers::deal::shuffle_deal, + tables::{ + GameTimer, PlayerClock, PlayerOrBot, bot, game_timer, lobby as _, player_clock, + player_hand, wall, + }, +}; + +mod deal; +mod hand; +mod lobby; + +#[reducer] +pub fn advance_game(ctx: &ReducerContext, mut game_timer: GameTimer) -> Result<(), String> { + // checks every second (or more? when users make moves) on whether to advance the game's various states + // TODO this, or allow player/debug to call this? + if !ctx.sender_auth().is_internal() { + return Err("This reducer can only be called by the scheduler".to_string()); + } + + if let Some(mut lobby) = ctx.db.lobby().id().find(game_timer.lobby_id) { + match lobby.game_state { + GameState::Setup => { + // TODO reduce interval beforehand so we don't wait a second? + // TODO keep a count to clear stale lobbies + lobby.game_state = GameState::Deal; + } + GameState::Deal => { + // TODO reduce interval beforehand so this can animate? + shuffle_deal(ctx, lobby.id); + } + GameState::Play => { + let curr_player = lobby.players.get(lobby.current_idx as usize).unwrap(); + match curr_player { + PlayerOrBot::Player { id: player_id } => { + let mut clock = ctx.db.player_clock().player_id().find(player_id).unwrap(); + let mut hand = ctx.db.player_hand().player_id().find(player_id).unwrap(); + match hand.turn_state { + TurnState::None => { + // TODO draw tile + if let Some(mut wall) = ctx.db.wall().lobby_id().find(lobby.id) + && let Some(tile) = wall.tiles.pop() + { + hand.working_tile = Some(tile); + hand.turn_state = TurnState::Tsumo; + ctx.db.wall().lobby_id().update(wall); + ctx.db.player_hand().id().update(hand); + } else { + // TODO out of tiles + todo!() + } + } + TurnState::Tsumo => { + if clock.tick() { + ctx.db.player_clock().id().update(clock); + } else { + // TODO auto-discard + } + } + TurnState::Menzen => {} + TurnState::RiichiKan => {} + TurnState::RonChiiPonKan => {} + TurnState::End => {} + } + } + PlayerOrBot::Bot { id: bot_id } => { + let b = ctx.db.bot().id().find(bot_id).unwrap(); + } + } + } + GameState::Exit => { + ctx.db.game_timer().id().delete(game_timer.id); + ctx.db.lobby().id().delete(lobby.id); + // TODO reset all player lobbies, delete bots, etc? + // is there a way to do this automatically, or rely on elsewhere's checks clearing the state? + return Ok(()); + } + + // TODO handle stale lobbies + // TODO should this delete the timer? + _ => Err(format!("lobby {} in impossible state", lobby.id))?, + } + + ctx.db.game_timer().id().update(game_timer); + } else { + ctx.db.game_timer().id().delete(game_timer.id); + Err(format!( + "ran schedule {} for empty lobby {}", + game_timer.id, game_timer.lobby_id + ))?; + } + + Ok(()) +} + +impl PlayerClock { + fn tick(&mut self) -> bool { + if self.renewable > 0 { + self.renewable -= 1; + true + } else if self.total > 0 { + self.total -= 1; + true + } else { + false + } + } + + fn renew(&mut self) { + self.renewable = 5; + } +} diff --git a/jong-line/src/reducers/deal.rs b/jong-line/src/reducers/deal.rs index e6e280f..a82e78a 100644 --- a/jong-line/src/reducers/deal.rs +++ b/jong-line/src/reducers/deal.rs @@ -1,18 +1,13 @@ use log::debug; use spacetimedb::{ReducerContext, Table, rand::seq::SliceRandom, reducer}; -use super::hand::deal_hands; use crate::tables::*; -#[reducer] pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) { debug!("lobby_id: {lobby_id}"); let mut lobby = ctx.db.lobby().id().find(lobby_id).unwrap(); - if lobby.game_state == jong_types::states::GameState::Setup { - lobby.game_state = jong_types::states::GameState::Deal; - lobby = ctx.db.lobby().id().update(lobby); - + if lobby.game_state == jong_types::states::GameState::Deal { let tiles = new_shuffled_wall(ctx); ctx.db.wall().insert(DbWall { @@ -24,7 +19,6 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) { deal_hands(ctx, lobby_id); lobby.game_state = jong_types::states::GameState::Play; - lobby.turn_state = jong_types::states::TurnState::Tsumo; ctx.db.lobby().id().update(lobby); } } @@ -39,3 +33,32 @@ pub fn new_shuffled_wall(ctx: &ReducerContext) -> Vec { wall } + +pub fn deal_hands(ctx: &ReducerContext, lobby_id: u32) { + let players = ctx.db.player().lobby_id().filter(lobby_id); + let bots = ctx.db.bot().lobby_id().filter(lobby_id); + + let mut wall = ctx.db.wall().lobby_id().find(lobby_id).unwrap(); + + // FIXME rectify deal orders + for player in players { + let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13); + wall = ctx.db.wall().lobby_id().update(wall); + tiles.sort_by_key(|t| t.tile); + ctx.db.player_hand().insert(PlayerHand { + id: 0, + player_id: player.id, + turn_state: jong_types::TurnState::None, + pond: vec![], + hand: tiles, + working_tile: None, + }); + } + for mut bot in bots { + let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13); + wall = ctx.db.wall().lobby_id().update(wall); + tiles.sort_by_key(|t| t.tile); + bot.hand = tiles; + ctx.db.bot().id().update(bot); + } +} diff --git a/jong-line/src/reducers/hand.rs b/jong-line/src/reducers/hand.rs index 842926a..be7b48f 100644 --- a/jong-line/src/reducers/hand.rs +++ b/jong-line/src/reducers/hand.rs @@ -1,66 +1,27 @@ use log::{debug, trace}; use spacetimedb::{ReducerContext, reducer}; -use crate::tables::{player::player, *}; use jong_types::states::TurnState; -pub fn deal_hands(ctx: &ReducerContext, lobby_id: u32) { - let players = ctx.db.player().lobby_id().filter(lobby_id); - let bots = ctx.db.bot().lobby_id().filter(lobby_id); - - let mut wall = ctx.db.wall().lobby_id().find(lobby_id).unwrap(); - - // FIXME rectify deal orders - for mut player in players { - let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13); - wall = ctx.db.wall().lobby_id().update(wall); - tiles.sort_by_key(|t| t.tile); - player.hand = tiles; - ctx.db.player().id().update(player); - } - for mut bot in bots { - let mut tiles = wall.tiles.split_off(wall.tiles.len() - 13); - wall = ctx.db.wall().lobby_id().update(wall); - tiles.sort_by_key(|t| t.tile); - bot.hand = tiles; - ctx.db.bot().id().update(bot); - } -} - -#[reducer] -pub fn draw_tile(ctx: &ReducerContext) { - let mut player = ctx.db.player().identity().find(ctx.sender).unwrap(); - let mut wall = ctx.db.wall().lobby_id().find(player.lobby_id).unwrap(); - - // TODO if no more tiles, exhaust somehow - - player.drawn_tile = wall.tiles.pop(); - - ctx.db.wall().lobby_id().update(wall); - ctx.db.player().id().update(player); -} +use crate::tables::*; // TODO make sure this can't be called or just error here? #[reducer] pub fn discard_tile(ctx: &ReducerContext, tile_id: u32) -> Result<(), String> { - let mut player = ctx.db.player().identity().find(ctx.sender).unwrap(); - let mut lobby = ctx.db.lobby().id().find(player.lobby_id).unwrap(); + let player = ctx.db.player().identity().find(ctx.sender).unwrap(); + let mut hand = ctx.db.player_hand().player_id().find(player.id).unwrap(); let dealt_tile = if let Some(dealt) = ctx.db.tile().id().find(tile_id) { - if let Some(drawn) = player.drawn_tile { + if let Some(drawn) = hand.working_tile { if drawn.id == dealt.id { // dealt from drawn tile dealt - } else if let Some((i, _)) = player - .hand - .iter() - .enumerate() - .find(|(_, t)| t.id == tile_id) + } else if let Some((i, _)) = hand.hand.iter().enumerate().find(|(_, t)| t.id == tile_id) { // dealt from hand - let dealt = player.hand.remove(i); - player.hand.push(drawn); - player.hand.sort_by_key(|t| t.tile); + let dealt = hand.hand.remove(i); + hand.hand.push(drawn); + hand.hand.sort_by_key(|t| t.tile); dealt } else { @@ -82,54 +43,53 @@ pub fn discard_tile(ctx: &ReducerContext, tile_id: u32) -> Result<(), String> { )); }; - player.pond.push(dealt_tile); - player.drawn_tile = None; - lobby.turn_state = TurnState::RonChiiPonKan; + hand.pond.push(dealt_tile); + hand.working_tile = None; + hand.turn_state = TurnState::None; - let player = ctx.db.player().id().update(player); - ctx.db.lobby().id().update(lobby); + ctx.db.player_hand().id().update(hand); debug!("player {} discarded tile {:?}", player.id, dealt_tile.tile); Ok(()) } -#[reducer] -pub fn skip_call(ctx: &ReducerContext) { - trace!("skip_call"); +// #[reducer] +// pub fn skip_call(ctx: &ReducerContext) { +// trace!("skip_call"); - let player = ctx.db.player().identity().find(ctx.sender).unwrap(); - let mut lobby = ctx.db.lobby().id().find(player.lobby_id).unwrap(); +// let player = ctx.db.player().identity().find(ctx.sender).unwrap(); +// let mut lobby = ctx.db.lobby().id().find(player.lobby_id).unwrap(); - lobby.turn_state = TurnState::Tsumo; - lobby.current_idx += 1; - if lobby.current_idx >= 3 { - lobby.current_idx = 0; - } +// lobby.turn_state = TurnState::Tsumo; +// lobby.current_idx += 1; +// if lobby.current_idx >= 3 { +// lobby.current_idx = 0; +// } - // FIXME where better can this go - bot_moves(ctx, &mut lobby); +// // FIXME where better can this go +// bot_moves(ctx, &mut lobby); - ctx.db.player().id().update(player); - ctx.db.lobby().id().update(lobby); -} +// ctx.db.player().id().update(player); +// ctx.db.lobby().id().update(lobby); +// } -fn bot_moves(ctx: &ReducerContext, lobby: &mut Lobby) { - let mut wall = ctx.db.wall().lobby_id().find(lobby.id).unwrap(); - if let Some(PlayerOrBot::Bot { id }) = lobby.players.get(lobby.current_idx as usize + 1) { - let mut bot = ctx.db.bot().id().find(id).unwrap(); - bot.pond.push(wall.tiles.pop().unwrap()); - ctx.db.bot().id().update(bot); - lobby.turn_state = TurnState::RonChiiPonKan; - } else { - lobby.turn_state = TurnState::Tsumo; - } +// fn bot_moves(ctx: &ReducerContext, lobby: &mut Lobby) { +// let mut wall = ctx.db.wall().lobby_id().find(lobby.id).unwrap(); +// if let Some(PlayerOrBot::Bot { id }) = lobby.players.get(lobby.current_idx as usize + 1) { +// let mut bot = ctx.db.bot().id().find(id).unwrap(); +// bot.pond.push(wall.tiles.pop().unwrap()); +// ctx.db.bot().id().update(bot); +// lobby.turn_state = TurnState::RonChiiPonKan; +// } else { +// lobby.turn_state = TurnState::Tsumo; +// } - lobby.current_idx += 1; - if lobby.current_idx >= 3 { - lobby.current_idx = 0; - } -} +// lobby.current_idx += 1; +// if lobby.current_idx >= 3 { +// lobby.current_idx = 0; +// } +// } // #[view(name = view_player_hand, public)] // pub fn view_player_hand(ctx: &ViewContext) -> Option { diff --git a/jong-line/src/reducers/lobby.rs b/jong-line/src/reducers/lobby.rs index f169dfc..b51aeac 100644 --- a/jong-line/src/reducers/lobby.rs +++ b/jong-line/src/reducers/lobby.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use log::info; use spacetimedb::{ReducerContext, Table, rand::seq::SliceRandom, reducer}; @@ -5,18 +7,16 @@ use crate::tables::*; #[reducer] pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<(), String> { - let ok_or = ctx + let mut player = ctx .db .player() .identity() .find(ctx.sender) .ok_or(format!("cannot find player {}", ctx.sender))?; - let mut player = ok_or; if lobby_id == 0 { let lobby = ctx.db.lobby().insert(Lobby { id: 0, - host_player_id: player.id, players: vec![PlayerOrBot::Player { id: player.id }], game_state: jong_types::states::GameState::Lobby, dealer_idx: 0, @@ -49,7 +49,8 @@ pub fn add_bot(ctx: &ReducerContext, lobby_id: u32) -> Result<(), String> { lobby_id, hand: vec![], pond: vec![], - drawn_tile: None, + working_tile: None, + turn_state: jong_types::TurnState::None, }); lobby.players.push(PlayerOrBot::Bot { id: bot.id }); ctx.db.lobby().id().update(lobby); @@ -61,29 +62,33 @@ pub fn add_bot(ctx: &ReducerContext, lobby_id: u32) -> Result<(), String> { } #[reducer] -pub fn set_ready(ctx: &ReducerContext, ready: bool) { +pub fn set_ready(ctx: &ReducerContext, ready: bool) -> Result<(), String> { let mut player = ctx.db.player().identity().find(ctx.sender).unwrap(); player.ready = ready; + player = ctx.db.player().identity().update(player); - ctx.db.player().identity().update(player); -} - -#[reducer] -pub fn start_game(ctx: &ReducerContext) { - let player = ctx.db.player().identity().find(ctx.sender).unwrap(); - if let Some(mut lobby) = ctx.db.lobby().host_player_id().find(player.id) + if let Some(mut lobby) = ctx.db.lobby().id().find(player.lobby_id) && lobby.players.len() == 4 - && lobby.players.iter().all(|p| match p { - PlayerOrBot::Player { id } => ctx.db.player().id().find(id).is_some_and(|p| p.ready), - PlayerOrBot::Bot { id } => ctx.db.bot().id().find(id).is_some(), - }) + && ctx.db.player().lobby_id().filter(lobby.id).all(|p| p.ready) { lobby.game_state = jong_types::states::GameState::Setup; lobby.players.shuffle(&mut ctx.rng()); - lobby.dealer_idx += 1; - if lobby.dealer_idx > 3 { - lobby.dealer_idx = 0; - } - ctx.db.lobby().id().update(lobby); + let lobby = ctx.db.lobby().id().update(lobby); + + // TODO should we schedule this outside so that we can clear out stale lobbies? + ctx.db.game_timer().insert(GameTimer { + id: 0, + lobby_id: lobby.id, + scheduled_at: spacetimedb::ScheduleAt::Interval(Duration::from_secs(1).into()), + }); + } else { + // if lobby doesn't exist, reset player state + player.lobby_id = 0; + player.ready = false; + player = ctx.db.player().identity().update(player); + + return Err(format!("couldn't find lobby with id: {}", player.lobby_id)); } + + Ok(()) } diff --git a/jong-line/src/tables.rs b/jong-line/src/tables.rs index 5939c67..a8ef7d5 100644 --- a/jong-line/src/tables.rs +++ b/jong-line/src/tables.rs @@ -1,3 +1,5 @@ +use std::time::Instant; + use spacetimedb::{SpacetimeType, table}; use jong_types::{ @@ -5,6 +7,8 @@ use jong_types::{ tiles::Tile, }; +use crate::reducers::advance_game; + #[derive(Debug, Clone)] #[table(name = lobby, public)] pub struct Lobby { @@ -12,8 +16,6 @@ pub struct Lobby { #[auto_inc] pub id: u32, - #[unique] - pub host_player_id: u32, pub players: Vec, pub dealer_idx: u8, pub current_idx: u8, @@ -45,41 +47,55 @@ pub enum PlayerOrBot { Bot { id: u32 }, } -#[table(name = advance_state_timer)] -pub struct AdvanceStateTimer { - #[primary_key] - #[auto_inc] - scheduled_id: u64, - scheduled_at: spacetimedb::ScheduleAt, - - lobby_id: u32, -} - // FIXME this shant be public, use views #[table(name = player, public)] +#[table(name = logged_out_player)] #[derive(Debug)] pub struct Player { - #[primary_key] - pub identity: spacetimedb::Identity, - #[unique] #[auto_inc] pub id: u32, + #[primary_key] + pub identity: spacetimedb::Identity, + pub name: Option, #[index(btree)] pub lobby_id: u32, pub ready: bool, + pub sort: bool, +} + +#[table(name = player_clock, public)] +pub struct PlayerClock { + #[primary_key] + pub id: u32, + + #[unique] + pub player_id: u32, + + pub renewable: u16, + pub total: u16, +} + +#[table(name = player_hand)] +pub struct PlayerHand { + #[primary_key] + #[auto_inc] + pub id: u32, + + #[unique] + pub player_id: u32, + pub turn_state: TurnState, - pub sort: bool, - - pub hand: Vec, pub pond: Vec, + pub hand: Vec, - pub drawn_tile: Option, + /// drawn or callable tile + pub working_tile: Option, } #[table(name = bot)] @@ -91,8 +107,22 @@ pub struct Bot { #[index(btree)] pub lobby_id: u32, + pub turn_state: TurnState, + pub hand: Vec, pub pond: Vec, - pub drawn_tile: Option, + pub working_tile: Option, +} + +#[table(name = game_timer, scheduled(advance_game))] +pub struct GameTimer { + #[primary_key] + #[auto_inc] + pub id: u64, + + #[unique] + pub lobby_id: u32, + + pub scheduled_at: spacetimedb::ScheduleAt, } diff --git a/jong/src/riichi.rs b/jong/src/riichi.rs index 38afe95..c8aa7d7 100644 --- a/jong/src/riichi.rs +++ b/jong/src/riichi.rs @@ -4,7 +4,7 @@ use bevy_spacetimedb::{ }; use jong_db::{self, DbConnection, LobbyTableAccess, PlayerTableAccess, RemoteTables}; -use jong_db::{add_bot, draw_tile, set_ready, shuffle_deal, skip_call, start_game}; +use jong_db::{add_bot, set_ready}; use jong_types::*; pub mod player; @@ -121,7 +121,7 @@ fn on_player_insert_update( }; for msg in messages.read() { - match msg.new.turn_state { + /* match msg.new.turn_state { jong_db::TurnState::None => {} jong_db::TurnState::Tsumo => { stdb.reducers().draw_tile().unwrap(); @@ -171,7 +171,7 @@ fn on_player_insert_update( if let Some(dbt) = &msg.new.drawn_tile { debug!("drew tile with id: {}", dbt.id); commands.spawn((Tile::from(&dbt.tile), TileId(dbt.id), Drawn)); - } + } */ } } @@ -205,12 +205,12 @@ fn on_lobby_insert_update( stdb.reducers().add_bot(player.lobby_id).unwrap(); } stdb.reducers().set_ready(true).unwrap(); - stdb.reducers().start_game().unwrap(); + // stdb.reducers().start_game().unwrap(); } } jong_db::GameState::Setup => { trace!("game entered setup"); - stdb.reducers().shuffle_deal(player.lobby_id).unwrap(); + // stdb.reducers().shuffle_deal(player.lobby_id).unwrap(); } jong_db::GameState::Deal => { trace!("game entered deal"); diff --git a/jong/src/tui/input/keyboard.rs b/jong/src/tui/input/keyboard.rs index be09002..91b8901 100644 --- a/jong/src/tui/input/keyboard.rs +++ b/jong/src/tui/input/keyboard.rs @@ -3,7 +3,6 @@ use bevy_ratatui::crossterm::event::KeyCode; use bevy_ratatui::event::KeyMessage; use jong_db::PlayerTableAccess; use jong_db::join_or_create_lobby; -use jong_db::start_game; use tui_logger::TuiWidgetEvent; use jong::SpacetimeDB; From 15e4425eb08c34bc5bf06776cad3fa3d0400cab7 Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Sat, 21 Feb 2026 16:55:37 -0800 Subject: [PATCH 2/5] update --- Cargo.lock | 186 ++++++++++++++++++++++++++-------------------------- Cargo.toml | 3 +- devenv.lock | 8 +-- 3 files changed, 98 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b30c07e..33f3bd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,9 +249,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "anymap" @@ -312,7 +312,7 @@ checksum = "f548ad2c4031f2902e3edc1f29c29e835829437de49562d8eb5dc5584d3a1043" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -518,7 +518,7 @@ checksum = "d577eae7246a1cda461df1b63188619fc6a3c619adba2a8e5a79e9aa51f64671" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -615,7 +615,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -715,7 +715,7 @@ checksum = "f9396b256b366a43d7f61d1f230cdab0a512fb4712cbf7d688f3d6fce4c5ea8a" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -782,7 +782,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -848,7 +848,7 @@ checksum = "92c4b3c3aac86f0db85d4f708883ebdc735c3f88ac5b84c033874fcdd3540a9d" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1049,7 +1049,7 @@ dependencies = [ "parking_lot", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "toml_edit", ] @@ -1271,7 +1271,7 @@ dependencies = [ "indexmap 2.13.0", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "uuid", ] @@ -1333,7 +1333,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1393,7 +1393,7 @@ checksum = "0d280e7e01308ef9b2629d888d71845f65c3f790f3dfedecc537182175527118" dependencies = [ "heck 0.5.0", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1477,7 +1477,7 @@ checksum = "bcda45913b1d6470c6b751656e72fb3f25ca6b5b7b2ee055b294aaed1eb7e5ba" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1701,7 +1701,7 @@ dependencies = [ "regex", "rustc-hash 2.1.1", "shlex", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1833,9 +1833,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.1" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytemuck" @@ -1854,7 +1854,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -1984,9 +1984,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.58" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63be97961acde393029492ce0be7a1af7e323e6bae9511ebfac33751be5e6806" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" dependencies = [ "clap_builder", "clap_derive", @@ -1994,9 +1994,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.58" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f13174bda5dfd69d7e947827e5af4b0f2f94a4a3ee92912fba07a66150f21e2" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" dependencies = [ "anstream", "anstyle", @@ -2013,7 +2013,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2456,7 +2456,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2469,7 +2469,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2480,7 +2480,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core 0.21.3", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2491,7 +2491,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core 0.23.0", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2524,9 +2524,9 @@ checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" [[package]] name = "deranged" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc3dc5ad92c2e2d1c193bbbbdf2ea477cb81331de4f3103f267ca18368b988c4" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ "powerfmt", "serde_core", @@ -2557,7 +2557,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2579,7 +2579,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.116", + "syn 2.0.117", "unicode-xid", ] @@ -2619,7 +2619,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2705,7 +2705,7 @@ checksum = "1796db3d892515842ca2dfb11124c4bb4a9e58d9f2c5c1072e5bca1b2334507b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2717,7 +2717,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -2953,7 +2953,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -3046,7 +3046,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -3238,7 +3238,7 @@ dependencies = [ "inflections", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -3687,14 +3687,14 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] name = "inventory" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc61209c082fbeb19919bee74b176221b27223e27b65d781eb91af24eb1fb46e" +checksum = "009ae045c87e7082cb72dab0ccd01ae075dd00141ddc108f43a0ea150a9e7227" dependencies = [ "rustversion", ] @@ -3820,9 +3820,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.85" +version = "0.3.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +checksum = "c7e709f3e3d22866f9c25b3aff01af289b18422cc8b4262fb19103ee80fe513d" dependencies = [ "once_cell", "wasm-bindgen", @@ -4169,9 +4169,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5d26952a508f321b4d3d2e80e78fc2603eaefcdf0c30783867f19586518bdc" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" dependencies = [ "libc", "log", @@ -4328,7 +4328,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -4360,7 +4360,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -4699,7 +4699,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -4834,7 +4834,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -4900,7 +4900,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -4929,7 +4929,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -5043,7 +5043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -5382,7 +5382,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -5615,9 +5615,9 @@ checksum = "4904c83c6e51f1b9b08bfa5a86f35a51798e8307186e6f5513852210a219c0bb" [[package]] name = "security-framework" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17b898a6d6948c3a8ee4372c17cb384f90d2e6e912ef00895b14fd7ab54ec38" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ "bitflags 2.11.0", "core-foundation 0.10.1", @@ -5628,9 +5628,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.16.0" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321c8673b092a9a42605034a9879d73cb79101ed5fd117bc9a597b89b4e9e61a" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -5681,7 +5681,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -5725,7 +5725,7 @@ dependencies = [ "darling 0.21.3", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -5926,7 +5926,7 @@ dependencies = [ "proc-macro2", "quote", "spacetimedb-primitives", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6161,7 +6161,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6173,7 +6173,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6206,9 +6206,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.116" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -6223,7 +6223,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6372,7 +6372,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6383,7 +6383,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6503,7 +6503,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6553,9 +6553,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.8+spec-1.1.0" +version = "1.0.9+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0742ff5ff03ea7e67c8ae6c93cac239e0d9784833362da3f9a9c1da8dfefcbdc" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" dependencies = [ "winnow", ] @@ -6579,7 +6579,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6866,7 +6866,7 @@ checksum = "41b6d82be61465f97d42bd1d15bf20f3b0a3a0905018f38f9d6f6962055b0b5c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -6932,9 +6932,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.108" +version = "0.2.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +checksum = "ec1adf1535672f5b7824f817792b1afd731d7e843d2d04ec8f27e8cb51edd8ac" dependencies = [ "cfg-if", "once_cell", @@ -6945,9 +6945,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.58" +version = "0.4.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f" +checksum = "fe88540d1c934c4ec8e6db0afa536876c5441289d7f9f9123d4f065ac1250a6b" dependencies = [ "cfg-if", "futures-util", @@ -6959,9 +6959,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.108" +version = "0.2.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +checksum = "19e638317c08b21663aed4d2b9a2091450548954695ff4efa75bff5fa546b3b1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6969,22 +6969,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.108" +version = "0.2.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +checksum = "2c64760850114d03d5f65457e96fc988f11f01d38fbaa51b254e4ab5809102af" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.108" +version = "0.2.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +checksum = "60eecd4fe26177cfa3339eb00b4a36445889ba3ad37080c2429879718e20ca41" dependencies = [ "unicode-ident", ] @@ -7133,9 +7133,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.85" +version = "0.3.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" +checksum = "9d6bb20ed2d9572df8584f6dc81d68a41a625cadc6f15999d649a70ce7e3597a" dependencies = [ "js-sys", "wasm-bindgen", @@ -7544,7 +7544,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -7555,7 +7555,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -7566,7 +7566,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -7577,7 +7577,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -8016,7 +8016,7 @@ dependencies = [ "heck 0.5.0", "indexmap 2.13.0", "prettyplease", - "syn 2.0.116", + "syn 2.0.117", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -8032,7 +8032,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -8168,7 +8168,7 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "synstructure", ] @@ -8195,7 +8195,7 @@ checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] @@ -8215,7 +8215,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", "synstructure", ] @@ -8249,7 +8249,7 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.116", + "syn 2.0.117", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 03b5cd3..2ca432f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ jong-types = { version = "0.1.0", path = "jong-types" } bevy.version = "0.17.3" bevy.default-features = false -bevy_ratatui = "0.10.0" +bevy_ratatui = "0.11.1" bevy_spacetimedb = "0.7" spacetimedb.version = "1.11.*" @@ -35,5 +35,4 @@ opt-level = 1 opt-level = 3 [patch.crates-io] -bevy_ratatui = { path = "/home/tao/clones/bevy_ratatui" } # bevy_spacetimedb = { path = "/home/tao/clones/bevy_spacetimedb/bevy_spacetimedb" } diff --git a/devenv.lock b/devenv.lock index 4ccffe2..3dda13a 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,10 +3,10 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1771157881, + "lastModified": 1771672827, "owner": "cachix", "repo": "devenv", - "rev": "b0b3dfa70ec90fa49f672e579f186faf4f61bd4b", + "rev": "6757a742f6393c7070f159eed9a59cbe20690aa3", "type": "github" }, "original": { @@ -125,10 +125,10 @@ ] }, "locked": { - "lastModified": 1771211437, + "lastModified": 1771642886, "owner": "oxalica", "repo": "rust-overlay", - "rev": "c62195b3d6e1bb11e0c2fb2a494117d3b55d410f", + "rev": "85078369717bdbe1f266c9eaad5e66956fb6feea", "type": "github" }, "original": { From d1446309c469e5137979d1df165eebc47f286e54 Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:00:35 -0800 Subject: [PATCH 3/5] update to bevy 0.18 --- Cargo.lock | 520 ++++++++++++++++++++++++++++++----------------------- Cargo.toml | 4 +- 2 files changed, 294 insertions(+), 230 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33f3bd7..87787c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -447,9 +447,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bevy" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3ee8652fe0577fd8a99054e147740850140d530be8e044a9be4e23a3e8a24" +checksum = "ec689b5a79452b6f777b889bbff22d3216b82a8d2ab7814d4a0eb571e9938d97" dependencies = [ "bevy_dylib", "bevy_internal", @@ -457,9 +457,9 @@ dependencies = [ [[package]] name = "bevy_a11y" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6702a82db1b383641fc7c503451847cdafb57076c203cd3bfe549d3eeef474c3" +checksum = "ef69b6d2dec07cbf407c63f6987e1746e4b735a9beea51f4bfc25ad49e344f75" dependencies = [ "accesskit", "bevy_app", @@ -470,18 +470,18 @@ dependencies = [ [[package]] name = "bevy_android" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42b2d9435e9fe8d7107bb795a6140277872ad5b992cb3934f8d28cfd11040f6f" +checksum = "008133458cfe0d43a8870bfc4c5a729467cc5d9246611462add38bcf45ed896f" dependencies = [ "android-activity", ] [[package]] name = "bevy_animation" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaf3ea6d435f4736b3deb60958270443501f5795c7964b1b504abd3be970b4f" +checksum = "13c852457843456c695ed22562969c83c3823454c3c40d359f92415371208ee7" dependencies = [ "bevy_animation_macros", "bevy_app", @@ -512,9 +512,9 @@ dependencies = [ [[package]] name = "bevy_animation_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d577eae7246a1cda461df1b63188619fc6a3c619adba2a8e5a79e9aa51f64671" +checksum = "ac120bfd5a74e05f96013817d28318dc716afaa68864af069c7ffc3ccaf9d153" dependencies = [ "bevy_macro_utils", "quote", @@ -523,9 +523,9 @@ dependencies = [ [[package]] name = "bevy_anti_alias" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15820535cc88bc280f55635eb3ea58df2703a434a0cc2343472eaa7e607fb27b" +checksum = "b418087f7c36a62c9886b55be6278e7b3d21c9943b107953aa2068000956a736" dependencies = [ "bevy_app", "bevy_asset", @@ -545,9 +545,9 @@ dependencies = [ [[package]] name = "bevy_app" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e4fc5dfe9d1d9b8233e1878353b5e66a3f5910c2131d3abf68f9a4116b2d433" +checksum = "2271a0123a7cc355c3fe98754360c75aa84b29f2a6b1a9f8c00aac427570d174" dependencies = [ "bevy_derive", "bevy_ecs", @@ -568,17 +568,19 @@ dependencies = [ [[package]] name = "bevy_asset" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357787dbfaba3f73fd185e15d6df70605bddaa774f2ebbcab1aaa031f21fb6c2" +checksum = "b1f7361669d1426a3359cb92f890ef9c62bd6e6b67f0190d2c5279d25ce24168" dependencies = [ "async-broadcast", + "async-channel", "async-fs", "async-lock", "atomicow", "bevy_android", "bevy_app", "bevy_asset_macros", + "bevy_diagnostic", "bevy_ecs", "bevy_platform", "bevy_reflect", @@ -593,8 +595,8 @@ dependencies = [ "either", "futures-io", "futures-lite", + "futures-util", "js-sys", - "parking_lot", "ron", "serde", "stackfuture", @@ -608,9 +610,9 @@ dependencies = [ [[package]] name = "bevy_asset_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa09271d4ca0bf31fda3a9ad57273775d448a05c4046d9367f71d29968d85b4" +checksum = "288e1edf17069afe2e02a0c0e7e5936b3d22a67c7d2dc9201a27e4451875f909" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -620,9 +622,9 @@ dependencies = [ [[package]] name = "bevy_audio" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79e56e072001524100b00e38cfdea302d9fdabbff48109fc67b528b27a237bb" +checksum = "e3cbecfc6c5d3860f224f56d3152b14aa313168d35c16e847f5a0202a992c3af" dependencies = [ "bevy_app", "bevy_asset", @@ -638,9 +640,9 @@ dependencies = [ [[package]] name = "bevy_camera" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8af1d5a57fde6e577e7b1db58996afb381618294be75a37b3070a20d309678b0" +checksum = "48c7e1f2a5da1755cd58e45c762f4ea2d72cef6c480f9c8ddbadbd2a4380c616" dependencies = [ "bevy_app", "bevy_asset", @@ -664,9 +666,9 @@ dependencies = [ [[package]] name = "bevy_color" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49504fac6b9897f03b4bdc0189c04ef1ba0a9b37926343aa520a71619e90e116" +checksum = "74727302424d7ffc23528a974dbb44a34708662926e1a3bfc5040493f858886e" dependencies = [ "bevy_math", "bevy_reflect", @@ -680,15 +682,16 @@ dependencies = [ [[package]] name = "bevy_core_pipeline" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af7e735685a652a8dba41b886f1330faeb57d4c61398917b7e49b09a7a1c3c1" +checksum = "a9e6bf0ba878bb5dd00ad4d70875b08eb11367829668c70d95785f5483ddb1cb" dependencies = [ "bevy_app", "bevy_asset", "bevy_camera", "bevy_color", "bevy_derive", + "bevy_diagnostic", "bevy_ecs", "bevy_image", "bevy_math", @@ -709,9 +712,9 @@ dependencies = [ [[package]] name = "bevy_derive" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9396b256b366a43d7f61d1f230cdab0a512fb4712cbf7d688f3d6fce4c5ea8a" +checksum = "70b6a05c31f54c83d681f1b8699bbaf581f06b25a40c9a6bb815625f731f5ba9" dependencies = [ "bevy_macro_utils", "quote", @@ -719,10 +722,39 @@ dependencies = [ ] [[package]] -name = "bevy_diagnostic" -version = "0.17.3" +name = "bevy_dev_tools" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cdb0ed0c8423570fbbb7c4fc2719a203dd40928fefff45f76ef0889685a446" +checksum = "f3183daa165acce210c50c170c47433c90b1d55932ead9734ebca14b7cd242c4" +dependencies = [ + "bevy_app", + "bevy_asset", + "bevy_camera", + "bevy_color", + "bevy_diagnostic", + "bevy_ecs", + "bevy_image", + "bevy_input", + "bevy_math", + "bevy_picking", + "bevy_reflect", + "bevy_render", + "bevy_shader", + "bevy_state", + "bevy_text", + "bevy_time", + "bevy_transform", + "bevy_ui", + "bevy_ui_render", + "bevy_window", + "tracing", +] + +[[package]] +name = "bevy_diagnostic" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aca4caa8a9014a435dca382b1bdebaee4363e9be69882c598fc4ff4d7cd56e6a" dependencies = [ "atomic-waker", "bevy_app", @@ -738,18 +770,18 @@ dependencies = [ [[package]] name = "bevy_dylib" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50a92aea6e896b6939ea51db6ced3a7e2dfd591016286e3eed9cb60d9e4f149" +checksum = "603d142e406440bf7508bb70188a5c8c48339151ccfa18aebf6f353d7a3e4134" dependencies = [ "bevy_internal", ] [[package]] name = "bevy_ecs" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7dd5229dd00d00e70ac6b2fc0a139961252f6ce07d3d268cfcac0da86d5bde4" +checksum = "24637a7c8643cab493f4085cda6bde4895f0e0816699c59006f18819da2ca0b8" dependencies = [ "arrayvec", "bevy_ecs_macros", @@ -775,9 +807,9 @@ dependencies = [ [[package]] name = "bevy_ecs_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d83bdd2285af4867e76c691406e0a4b55611b583d0c45b6ac7bcec1b45fd48" +checksum = "6eb14c18ca71e11c69fbae873c2db129064efac6d52e48d0127d37bfba1acfa8" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -787,9 +819,9 @@ dependencies = [ [[package]] name = "bevy_encase_derive" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7179e985f3f1b99265cb87fe194db3b00aee8e2914888d621ff9826e1417ee19" +checksum = "0f89146a8fcbfe47310fc929ee762dd3b08d4de3e3371c601529cfa8eeb861de" dependencies = [ "bevy_macro_utils", "encase_derive_impl", @@ -797,9 +829,9 @@ dependencies = [ [[package]] name = "bevy_gilrs" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a39dd8fdfe93314d47355ab3c58da40b648908a368bc536872f75fad4e8f3755" +checksum = "6c76417261ff3cd7ecda532b58514224aee06e76fbd87636c3a80695be7c8192" dependencies = [ "bevy_app", "bevy_ecs", @@ -813,38 +845,29 @@ dependencies = [ [[package]] name = "bevy_gizmos" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebb9e3ca4938b48e5111151ce4b08f0e6fc207b854db08fa2d8de15ecabe8f8" +checksum = "bc78a5699580c2dce078f4c099028d26525a5a38e8eb587a31854c660a3c5ff7" dependencies = [ "bevy_app", "bevy_asset", "bevy_camera", "bevy_color", - "bevy_core_pipeline", "bevy_ecs", "bevy_gizmos_macros", - "bevy_image", "bevy_light", "bevy_math", - "bevy_mesh", - "bevy_pbr", "bevy_reflect", - "bevy_render", - "bevy_shader", - "bevy_sprite_render", "bevy_time", "bevy_transform", "bevy_utils", - "bytemuck", - "tracing", ] [[package]] name = "bevy_gizmos_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c4b3c3aac86f0db85d4f708883ebdc735c3f88ac5b84c033874fcdd3540a9d" +checksum = "60bb92e0ef80ff7c59429133244765515db3d313fae77ee67ffe94dab5b2725d" dependencies = [ "bevy_macro_utils", "quote", @@ -852,11 +875,37 @@ dependencies = [ ] [[package]] -name = "bevy_gltf" -version = "0.17.3" +name = "bevy_gizmos_render" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3479fbaf897320a3ee30c1626b4a1bee0be874ca27699c3b2f3494891d103d9b" +checksum = "48fde3172a31f81033b4f497dd9df84476f527fadb00936ede380fb646c402eb" dependencies = [ + "bevy_app", + "bevy_asset", + "bevy_camera", + "bevy_core_pipeline", + "bevy_ecs", + "bevy_gizmos", + "bevy_image", + "bevy_math", + "bevy_mesh", + "bevy_pbr", + "bevy_render", + "bevy_shader", + "bevy_sprite_render", + "bevy_transform", + "bevy_utils", + "bytemuck", + "tracing", +] + +[[package]] +name = "bevy_gltf" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08372f222676dba313061fc71128209b82f9711e7c5cba222b5c34bf1c5c70fe" +dependencies = [ + "async-lock", "base64 0.22.1", "bevy_animation", "bevy_app", @@ -888,9 +937,9 @@ dependencies = [ [[package]] name = "bevy_image" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d546bbe2486bfa14971517e7ef427a9384749817c201d3afc60de0325cf52f11" +checksum = "809101ebe678a76c4c5ba3ecad255cde9be3ae0af591cf0143ba2c157afb55e9" dependencies = [ "bevy_app", "bevy_asset", @@ -917,9 +966,9 @@ dependencies = [ [[package]] name = "bevy_input" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca955b99f4dc2059e9c8574f8d95a5dd5002809fda80d062a94a553c571a467" +checksum = "9c2853993baf27b963a417d3603a73e02e39c5041913cd1ba7211b0a3037b191" dependencies = [ "bevy_app", "bevy_ecs", @@ -934,9 +983,9 @@ dependencies = [ [[package]] name = "bevy_input_focus" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4d1d0e833e31beba1f28a77152b35f946e8c45df364ec4969d58788ab9de7f" +checksum = "05fc0fae5e4e081180f7f7bf8023a2b97dad13dcb5fa79eba50cda5bb95699a9" dependencies = [ "bevy_app", "bevy_ecs", @@ -951,9 +1000,9 @@ dependencies = [ [[package]] name = "bevy_internal" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5e645f9e1a24c9667c768b6233beaf4e241739d8ca4fbba59435cc27aabad5" +checksum = "57463815630ea71221c0b8e7bff72d816a3071a89507c45f9e2686fbb5e1956b" dependencies = [ "bevy_a11y", "bevy_android", @@ -966,10 +1015,12 @@ dependencies = [ "bevy_color", "bevy_core_pipeline", "bevy_derive", + "bevy_dev_tools", "bevy_diagnostic", "bevy_ecs", "bevy_gilrs", "bevy_gizmos", + "bevy_gizmos_render", "bevy_gltf", "bevy_image", "bevy_input", @@ -1003,9 +1054,9 @@ dependencies = [ [[package]] name = "bevy_light" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47093733280976ebd595f6e25f76603d5067ca4eb7544e59ecb0dd2fc5147810" +checksum = "4f9968b8f8a6a766a88b66144474c39d1415edc277d042fec1526eae85e1f8b4" dependencies = [ "bevy_app", "bevy_asset", @@ -1024,9 +1075,9 @@ dependencies = [ [[package]] name = "bevy_log" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a2d4ea086ac4663ab9dfb056c7b85eee39e18f7e3e9a4ae6e39897eaa155c5" +checksum = "406304a9b867a2de98c3edf0cc9e5a608fad1a1ddc567e15e72c186a8273ef51" dependencies = [ "android_log-sys", "bevy_app", @@ -1042,11 +1093,10 @@ dependencies = [ [[package]] name = "bevy_macro_utils" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62d984f9f8bd0f0d9fb020492a955e641e30e7a425f3588bf346cb3e61fec3c3" +checksum = "0b7272fca0bf30d8ca2571a803598856104b63e5c596d52850f811ed37c5e1e3" dependencies = [ - "parking_lot", "proc-macro2", "quote", "syn 2.0.117", @@ -1055,11 +1105,12 @@ dependencies = [ [[package]] name = "bevy_math" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa74ae5d968749cc073da991757d3c7e3504ac6dbaac5f8c2a54b9d19b0b7ed" +checksum = "6a815c514b8a6f7b11508cdc8b3a4bf0761e96a14227af40aa93cb1160989ce0" dependencies = [ "approx 0.5.1", + "arrayvec", "bevy_reflect", "derive_more 2.1.1", "glam", @@ -1068,16 +1119,15 @@ dependencies = [ "rand 0.9.2", "rand_distr", "serde", - "smallvec", "thiserror 2.0.18", "variadics_please", ] [[package]] name = "bevy_mesh" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9a0ea86abbd17655bc6f9f8d94461dfcd0322431f752fc03748df8b335eff2" +checksum = "aacf09d0ffd1a15baf8d201c4a34b918912a506395c2817aa55ab3d3776c09f2" dependencies = [ "bevy_app", "bevy_asset", @@ -1106,9 +1156,9 @@ checksum = "7ef8e4b7e61dfe7719bb03c884dc270cd46a82efb40f93e9933b990c5c190c59" [[package]] name = "bevy_pbr" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c514b950cda849aa64e9b076a235913577370275125a34a478758505a19d776" +checksum = "69cc361c65035f7e531b592d99bce95b6ab3f643cae2abe97dfa7681363159a6" dependencies = [ "bevy_app", "bevy_asset", @@ -1120,6 +1170,7 @@ dependencies = [ "bevy_ecs", "bevy_image", "bevy_light", + "bevy_log", "bevy_math", "bevy_mesh", "bevy_platform", @@ -1142,9 +1193,9 @@ dependencies = [ [[package]] name = "bevy_picking" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b371779713b40dea83b24cdb95054fe999fe8372351a317c4fb768859ac5f010" +checksum = "e4d10bb2a776087e1d8a9b87e8deb091d25bcedbe6160c613df2dc5fe069c3c5" dependencies = [ "bevy_app", "bevy_asset", @@ -1166,14 +1217,13 @@ dependencies = [ [[package]] name = "bevy_platform" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4691af6d7cfd1b5deb2fc926a43a180a546cdc3fe1e5a013fcee60db9bb2c81f" +checksum = "9b29ea749a8e85f98186ab662f607b885b97c804bb14cdb0cdf838164496d474" dependencies = [ "critical-section", "foldhash 0.2.0", "futures-channel", - "getrandom 0.3.4", "hashbrown 0.16.1", "js-sys", "portable-atomic", @@ -1187,9 +1237,9 @@ dependencies = [ [[package]] name = "bevy_post_process" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b857972f5d56b43b0dce2c843b75b64d5fbbd0f6177f6ecccd75e7e41f72deb" +checksum = "e8e1116cbc35637f267a29c7d2fe376e020f2b4402d6b525d328bae9c10460c7" dependencies = [ "bevy_app", "bevy_asset", @@ -1217,27 +1267,28 @@ dependencies = [ [[package]] name = "bevy_ptr" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d24d7906c7de556033168b3485de36c59049fbaef0c2c44c715a23e0329b10" +checksum = "4f98cbc6d34bbdb58240b72ed1731931b4991a893b3a3238bb7c42ae054aa676" [[package]] name = "bevy_ratatui" -version = "0.10.0" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24368df4cff95c92448a33c46f7db4ff51016a3024d27bd2daa49d0e3ce03f4" dependencies = [ "bevy", "bitflags 2.11.0", "color-eyre", "ratatui", - "smol_str", "tracing", ] [[package]] name = "bevy_reflect" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5472b91928c0f3e4e3988c0d036b00719f19520f53a0c3f8c2af72f00e693c5" +checksum = "2b2a977e2b8dba65b6e9c11039c5f9ef108be428f036b3d1cac13ad86ec59f9c" dependencies = [ "assert_type_match", "bevy_platform", @@ -1250,6 +1301,7 @@ dependencies = [ "erased-serde", "foldhash 0.2.0", "glam", + "indexmap 2.13.0", "inventory", "petgraph", "serde", @@ -1263,9 +1315,9 @@ dependencies = [ [[package]] name = "bevy_reflect_derive" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083784255162fa39960aa3cf3c23af0e515db2daa7f2e796ae34df993f4d3f6c" +checksum = "067af30072b1611fda1a577f1cb678b8ea2c9226133068be808dd49aac30cef0" dependencies = [ "bevy_macro_utils", "indexmap 2.13.0", @@ -1277,9 +1329,9 @@ dependencies = [ [[package]] name = "bevy_render" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44117cbc9448b5a3118eb9c65bd9ec4c574be996148793be2443257daae6eb05" +checksum = "d6b2c9a276646bde8ba58a7e15711b459fb4a5cdf46c47059b7a310f97a70d9c" dependencies = [ "async-channel", "bevy_app", @@ -1308,6 +1360,7 @@ dependencies = [ "downcast-rs 2.0.2", "encase", "fixedbitset 0.5.7", + "glam", "image", "indexmap 2.13.0", "js-sys", @@ -1326,9 +1379,9 @@ dependencies = [ [[package]] name = "bevy_render_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9557b7b6b06b1b70c147581f4f410c2de73b6f6f0e82915887020f953bacb5a" +checksum = "03e16b8cac95b87021399ed19f6ab79c0b1e03101a448e3a0240934f78f66a56" dependencies = [ "bevy_macro_utils", "proc-macro2", @@ -1338,9 +1391,9 @@ dependencies = [ [[package]] name = "bevy_scene" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf6efd31fdd1e05724c95900bb1055716c8e3633b05fa731ee75db4241c17d" +checksum = "0046bb071ee358619f2fa9409ccced47375502b098b4107ec3385f3a1acf6600" dependencies = [ "bevy_app", "bevy_asset", @@ -1352,6 +1405,7 @@ dependencies = [ "bevy_transform", "bevy_utils", "derive_more 2.1.1", + "ron", "serde", "thiserror 2.0.18", "uuid", @@ -1359,9 +1413,9 @@ dependencies = [ [[package]] name = "bevy_shader" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a655de9f64e113a6e37be76401fb0d6cb84ed7cc4f891e70af4e39d26e9080c3" +checksum = "4a14cb0991b2482a66b94728cbcf7482d1b74364be017197396435d3d542b8d3" dependencies = [ "bevy_asset", "bevy_platform", @@ -1377,8 +1431,6 @@ dependencies = [ [[package]] name = "bevy_spacetimedb" version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aee7e9cf362911e4b4ed28f25a16bdc1ada1178375302385c8f5595e35f4d1f" dependencies = [ "bevy", "bevy_spacetimedb_macros", @@ -1398,9 +1450,9 @@ dependencies = [ [[package]] name = "bevy_sprite" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52b9a80aadf102ef0b012ceba5326253638c891994c303479e9973092e4e1c8b" +checksum = "b2b3921ce1a8ce801c29d9552cbc204548bfeb16b9b829045c9e82b5917d99cc" dependencies = [ "bevy_app", "bevy_asset", @@ -1423,9 +1475,9 @@ dependencies = [ [[package]] name = "bevy_sprite_render" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eec49a2a9185526f9828559a40b6f66d4c2dbae2df8ea2936d88ba449a5e86a" +checksum = "ed40642fa0e1330df65b6a1bf0b14aa32fcd9d7f3306e08e0784c10362bd6265" dependencies = [ "bevy_app", "bevy_asset", @@ -1455,9 +1507,9 @@ dependencies = [ [[package]] name = "bevy_state" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e8556a55d548844fc067fac6657b62f8073c94bd7e13c86aa7573f4c2a67b3" +checksum = "9453325ca0c185a043f4515158daa15a8ab19139a60fd1edaf87fbe896cb7f83" dependencies = [ "bevy_app", "bevy_ecs", @@ -1471,9 +1523,9 @@ dependencies = [ [[package]] name = "bevy_state_macros" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda45913b1d6470c6b751656e72fb3f25ca6b5b7b2ee055b294aaed1eb7e5ba" +checksum = "d733081e57e49b3c43bdf3766d1de74c7df32e0f4db20c20437c85b1d18908de" dependencies = [ "bevy_macro_utils", "quote", @@ -1482,9 +1534,9 @@ dependencies = [ [[package]] name = "bevy_tasks" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbbfa5a58a16c4228434d3018c23fde3d78dcd76ec5f5b2b482a21f4b158dd3" +checksum = "990ffedd374dd2c4fe8f0fd4bcefd5617d1ee59164b6c3fcc356a69b48e26e8e" dependencies = [ "async-channel", "async-executor", @@ -1501,9 +1553,9 @@ dependencies = [ [[package]] name = "bevy_text" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc144cc6a30ed44a88e342c22d9e3a66a0993a74f792ae07ba79318efb41a86d" +checksum = "ecbb6eeaa9a63d1f8aae8c0d79f8d5e14c584a962a4ef9f69115fd7d10941101" dependencies = [ "bevy_app", "bevy_asset", @@ -1527,9 +1579,9 @@ dependencies = [ [[package]] name = "bevy_time" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32835c3dbe082fbbe7d4f2f37f655073421f2882d4320ac2d59f922474260de4" +checksum = "e4c68b78e7ca1cc10c811cd1ded8350f53f2be11eb46946879a74c684026bff7" dependencies = [ "bevy_app", "bevy_ecs", @@ -1542,9 +1594,9 @@ dependencies = [ [[package]] name = "bevy_transform" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41fabfeaa53f51ff5ccf4d87e66836293159d50d21f6d3e16c93efb7c30f969" +checksum = "b30e3957de42c2f7d88dfe8428e739b74deab8932d2a8bbb9d4eefbd64b6aa34" dependencies = [ "bevy_app", "bevy_ecs", @@ -1560,9 +1612,9 @@ dependencies = [ [[package]] name = "bevy_ui" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0fe27b8c641c2537480774dfd9198d56779371b04dd76618db39da4e7c7483" +checksum = "889c6892e9c5c308ab225a1322d07fb2358ccf39493526cda4d5f083d717773d" dependencies = [ "accesskit", "bevy_a11y", @@ -1574,6 +1626,7 @@ dependencies = [ "bevy_ecs", "bevy_image", "bevy_input", + "bevy_input_focus", "bevy_math", "bevy_picking", "bevy_platform", @@ -1593,9 +1646,9 @@ dependencies = [ [[package]] name = "bevy_ui_render" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1d2e783bb5f0b748e6360a0055421d5c934b43830b205a84996a75e54330cd7" +checksum = "b649395e32a4761d4f17aeff37170a4421c94a14c505645397b8ee8510eb19e9" dependencies = [ "bevy_app", "bevy_asset", @@ -1624,9 +1677,9 @@ dependencies = [ [[package]] name = "bevy_utils" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789d04f88c764877a4552e07745b402dbc45f5d0545e6d102558f2f1752a1d89" +checksum = "e258c44d869f9c41ac0f88a16815c67f2569eb9fff4716828a40273d127b6f84" dependencies = [ "bevy_platform", "disqualified", @@ -1635,9 +1688,9 @@ dependencies = [ [[package]] name = "bevy_window" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae54ec7a0fc344278592a688a01b57b32182abc3ca7d47040773c4cbc2e15e0" +checksum = "869a56f1da2544641734018e1f1caa660299cd6e3af794f3fa0df72293d8eed2" dependencies = [ "bevy_app", "bevy_asset", @@ -1654,9 +1707,9 @@ dependencies = [ [[package]] name = "bevy_winit" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feeaa46d3c4480323e690de8a4ca7f914c074af1f5f70ee3246392992dbf4a0c" +checksum = "8142a3749fc491eeae481c30bb3830cf5a71d2fa3dba4d450a42792f6d39eb2d" dependencies = [ "accesskit", "accesskit_winit", @@ -2222,6 +2275,15 @@ dependencies = [ "libc", ] +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + [[package]] name = "coreaudio-rs" version = "0.11.3" @@ -2244,21 +2306,22 @@ dependencies = [ [[package]] name = "cosmic-text" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da46a9d5a8905cc538a4a5bceb6a4510de7a51049c5588c0114efce102bcbbe8" +checksum = "c4cadaea21e24c49c0c82116f2b465ae6a49d63c90e428b0f8d9ae1f638ac91f" dependencies = [ "bitflags 2.11.0", "fontdb", + "harfrust", + "linebender_resource_handle", "log", "rangemap", "rustc-hash 1.1.0", - "rustybuzz", "self_cell", + "skrifa 0.39.0", "smol_str", "swash", "sys-locale", - "ttf-parser 0.21.1", "unicode-bidi", "unicode-linebreak", "unicode-script", @@ -2678,30 +2741,29 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "encase" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02ba239319a4f60905966390f5e52799d868103a533bb7e27822792332504ddd" +checksum = "6e3e0ff2ee0b7aa97428308dd9e1e42369cb22f5fb8dc1c55546637443a60f1e" dependencies = [ "const_panic", "encase_derive", - "glam", "thiserror 2.0.18", ] [[package]] name = "encase_derive" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5223d6c647f09870553224f6e37261fe5567bc5a4f4cf13ed337476e79990f2f" +checksum = "a4d90c5d7d527c6cb8a3b114efd26a6304d9ab772656e73d8f4e32b1f3d601a2" dependencies = [ "encase_derive_impl", ] [[package]] name = "encase_derive_impl" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1796db3d892515842ca2dfb11124c4bb4a9e58d9f2c5c1072e5bca1b2334507b" +checksum = "c8bad72d8308f7a382de2391ec978ddd736e0103846b965d7e2a63a75768af30" dependencies = [ "proc-macro2", "quote", @@ -2914,16 +2976,16 @@ dependencies = [ [[package]] name = "fontdb" -version = "0.16.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0299020c3ef3f60f526a4f64ab4a3d4ce116b1acbf24cdd22da0068e5d81dc3" +checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" dependencies = [ "fontconfig-parser", "log", "memmap2", "slotmap", "tinyvec", - "ttf-parser 0.20.0", + "ttf-parser", ] [[package]] @@ -3116,11 +3178,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", - "js-sys", "libc", "r-efi", "wasip2", - "wasm-bindgen", ] [[package]] @@ -3194,6 +3254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9" dependencies = [ "bytemuck", + "encase", "libm", "rand 0.9.2", "serde_core", @@ -3315,9 +3376,9 @@ dependencies = [ [[package]] name = "grid" -version = "0.15.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36119f3a540b086b4e436bb2b588cf98a68863470e0e880f4d0842f112a3183a" +checksum = "f9e2d4c0a8296178d8802098410ca05d86b17a10bb5ab559b3fb404c1f948220" [[package]] name = "guillotiere" @@ -3341,6 +3402,19 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "harfrust" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0caaee032384c10dd597af4579c67dee16650d862a9ccbe1233ff1a379abc07" +dependencies = [ + "bitflags 2.11.0", + "bytemuck", + "core_maths", + "read-fonts 0.36.0", + "smallvec", +] + [[package]] name = "hash32" version = "0.3.1" @@ -3381,9 +3455,9 @@ dependencies = [ [[package]] name = "heapless" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +checksum = "2af2455f757db2b292a9b1768c4b70186d443bcb3b316252d6b540aec1cd89ed" dependencies = [ "hash32", "portable-atomic", @@ -3955,6 +4029,12 @@ dependencies = [ "bitflags 2.11.0", ] +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -4125,9 +4205,9 @@ dependencies = [ [[package]] name = "naga" -version = "26.0.0" +version = "27.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916cbc7cb27db60be930a4e2da243cf4bc39569195f22fd8ee419cd31d5b662c" +checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" dependencies = [ "arrayvec", "bit-set 0.8.0", @@ -4136,7 +4216,7 @@ dependencies = [ "cfg_aliases", "codespan-reporting", "half", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "hexf-parse", "indexmap 2.13.0", "libm", @@ -4152,9 +4232,9 @@ dependencies = [ [[package]] name = "naga_oil" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b586d3cf5c9b7e13fe2af6e114406ff70773fd80881960378933b63e76f37dd" +checksum = "310c347db1b30e69581f3b84dc9a5c311ed583f67851b39b77953cb7a066c97f" dependencies = [ "codespan-reporting", "data-encoding", @@ -4754,7 +4834,7 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" dependencies = [ - "ttf-parser 0.25.1", + "ttf-parser", ] [[package]] @@ -5332,6 +5412,17 @@ dependencies = [ "font-types", ] +[[package]] +name = "read-fonts" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eaa2941a4c05443ee3a7b26ab076a553c343ad5995230cc2b1d3e993bdc6345" +dependencies = [ + "bytemuck", + "core_maths", + "font-types", +] + [[package]] name = "rectangle-pack" version = "0.4.2" @@ -5432,14 +5523,15 @@ dependencies = [ [[package]] name = "ron" -version = "0.10.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beceb6f7bf81c73e73aeef6dd1356d9a1b2b4909e1f0fc3e59b034f9572d7b7f" +checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" dependencies = [ - "base64 0.22.1", "bitflags 2.11.0", + "once_cell", "serde", "serde_derive", + "typeid", "unicode-ident", ] @@ -5508,23 +5600,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" -[[package]] -name = "rustybuzz" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb9cf8877777222e4a3bc7eb247e398b56baba500c38c1c46842431adc8b55c" -dependencies = [ - "bitflags 2.11.0", - "bytemuck", - "libm", - "smallvec", - "ttf-parser 0.21.1", - "unicode-bidi-mirroring", - "unicode-ccc", - "unicode-properties", - "unicode-script", -] - [[package]] name = "ruzstd" version = "0.8.2" @@ -5825,7 +5900,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c31071dedf532758ecf3fed987cdb4bd9509f900e026ab684b4ecb81ea49841" dependencies = [ "bytemuck", - "read-fonts", + "read-fonts 0.35.0", +] + +[[package]] +name = "skrifa" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9eb0b904a04d09bd68c65d946617b8ff733009999050f3b851c32fb3cfb60e" +dependencies = [ + "bytemuck", + "read-fonts 0.36.0", ] [[package]] @@ -6188,7 +6273,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47846491253e976bdd07d0f9cc24b7daf24720d11309302ccbbc6e6b6e53550a" dependencies = [ - "skrifa", + "skrifa 0.37.0", "yazi", "zeno", ] @@ -6251,9 +6336,9 @@ dependencies = [ [[package]] name = "taffy" -version = "0.7.7" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4f4d046dd956a47a7e1a2947083d7ac3e6aa3cfaaead36173ceaa5ab11878c" +checksum = "41ba83ebaf2954d31d05d67340fd46cebe99da2b7133b0dd68d70c65473a437b" dependencies = [ "arrayvec", "grid", @@ -6654,23 +6739,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "ttf-parser" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" - -[[package]] -name = "ttf-parser" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8" - [[package]] name = "ttf-parser" version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] [[package]] name = "tui-logger" @@ -6744,18 +6820,6 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" -[[package]] -name = "unicode-bidi-mirroring" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cb788ffebc92c5948d0e997106233eeb1d8b9512f93f41651f52b6c5f5af86" - -[[package]] -name = "unicode-ccc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656" - [[package]] name = "unicode-ident" version = "1.0.24" @@ -6768,12 +6832,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" -[[package]] -name = "unicode-properties" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" - [[package]] name = "unicode-script" version = "0.5.8" @@ -7225,16 +7283,16 @@ dependencies = [ [[package]] name = "wgpu" -version = "26.0.1" +version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70b6ff82bbf6e9206828e1a3178e851f8c20f1c9028e74dd3a8090741ccd5798" +checksum = "bfe68bac7cde125de7a731c3400723cadaaf1703795ad3f4805f187459cd7a77" dependencies = [ "arrayvec", "bitflags 2.11.0", "cfg-if", "cfg_aliases", "document-features", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "js-sys", "log", "naga", @@ -7252,17 +7310,18 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "26.0.1" +version = "27.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f62f1053bd28c2268f42916f31588f81f64796e2ff91b81293515017ca8bd9" +checksum = "27a75de515543b1897b26119f93731b385a19aea165a1ec5f0e3acecc229cae7" dependencies = [ "arrayvec", "bit-set 0.8.0", "bit-vec 0.8.0", "bitflags 2.11.0", + "bytemuck", "cfg_aliases", "document-features", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "indexmap 2.13.0", "log", "naga", @@ -7283,36 +7342,36 @@ dependencies = [ [[package]] name = "wgpu-core-deps-apple" -version = "26.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18ae5fbde6a4cbebae38358aa73fcd6e0f15c6144b67ef5dc91ded0db125dbdf" +checksum = "0772ae958e9be0c729561d5e3fd9a19679bcdfb945b8b1a1969d9bfe8056d233" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-wasm" -version = "26.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03b9f9e1a50686d315fc6debe4980cc45cd37b0e919351917df494e8fdc8885" +checksum = "9b1027dcf3b027a877e44819df7ceb0e2e98578830f8cd34cd6c3c7c2a7a50b7" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-windows-linux-android" -version = "26.0.0" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "720a5cb9d12b3d337c15ff0e24d3e97ed11490ff3f7506e7f3d98c68fa5d6f14" +checksum = "71197027d61a71748e4120f05a9242b2ad142e3c01f8c1b47707945a879a03c3" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-hal" -version = "26.0.6" +version = "27.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d0e67224cc7305b3b4eb2cc57ca4c4c3afc665c1d1bee162ea806e19c47bdd" +checksum = "5b21cb61c57ee198bc4aff71aeadff4cbb80b927beb912506af9c780d64313ce" dependencies = [ "android_system_properties", "arrayvec", @@ -7329,7 +7388,7 @@ dependencies = [ "gpu-alloc", "gpu-allocator", "gpu-descriptor", - "hashbrown 0.15.5", + "hashbrown 0.16.1", "js-sys", "khronos-egl", "libc", @@ -7339,6 +7398,7 @@ dependencies = [ "naga", "ndk-sys 0.6.0+11769913", "objc", + "once_cell", "ordered-float 5.0.0", "parking_lot", "portable-atomic", @@ -7358,9 +7418,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "26.0.0" +version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca7a8d8af57c18f57d393601a1fb159ace8b2328f1b6b5f80893f7d672c9ae2" +checksum = "afdcf84c395990db737f2dd91628706cb31e86d72e53482320d368e52b5da5eb" dependencies = [ "bitflags 2.11.0", "bytemuck", @@ -8257,3 +8317,7 @@ name = "zmij" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + +[[patch.unused]] +name = "bevy_ratatui" +version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index 2ca432f..cecf3ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = ["jong", "jong-types", "jong-line", "jong-db"] jong = { version = "0.1.0", path = "jong" } jong-types = { version = "0.1.0", path = "jong-types" } -bevy.version = "0.17.3" +bevy.version = "0.18" bevy.default-features = false bevy_ratatui = "0.11.1" @@ -35,4 +35,4 @@ opt-level = 1 opt-level = 3 [patch.crates-io] -# bevy_spacetimedb = { path = "/home/tao/clones/bevy_spacetimedb/bevy_spacetimedb" } +bevy_spacetimedb = { path = "bevy_spacetimedb/bevy_spacetimedb" } From d7b4221727af64a66cd8afb4b290741402403294 Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:08:02 -0800 Subject: [PATCH 4/5] codegen --- jong-db/src/db/add_bot_reducer.rs | 44 +-- jong-db/src/db/advance_game_reducer.rs | 44 +-- jong-db/src/db/advance_state_timer_table.rs | 144 ------- jong-db/src/db/advance_state_timer_type.rs | 17 - jong-db/src/db/bot_table.rs | 81 ++-- jong-db/src/db/bot_type.rs | 17 +- jong-db/src/db/clear_all_reducer.rs | 43 +-- jong-db/src/db/connect_reducer.rs | 43 +-- jong-db/src/db/db_tile_type.rs | 9 +- jong-db/src/db/db_wall_type.rs | 11 +- jong-db/src/db/discard_tile_reducer.rs | 45 +-- jong-db/src/db/disconnect_reducer.rs | 43 +-- jong-db/src/db/dragon_type.rs | 11 +- jong-db/src/db/draw_tile_reducer.rs | 100 ----- jong-db/src/db/game_state_type.rs | 11 +- jong-db/src/db/game_timer_table.rs | 133 ++++--- jong-db/src/db/game_timer_type.rs | 10 +- .../src/db/join_or_create_lobby_reducer.rs | 51 ++- jong-db/src/db/lobby_table.rs | 81 ++-- jong-db/src/db/lobby_type.rs | 13 +- jong-db/src/db/logged_out_player_table.rs | 135 ++++--- jong-db/src/db/login_or_add_player_reducer.rs | 103 ----- jong-db/src/db/mod.rs | 358 +++++++++++------- jong-db/src/db/player_clock_table.rs | 133 ++++--- jong-db/src/db/player_clock_type.rs | 10 +- jong-db/src/db/player_hand_table.rs | 135 ++++--- jong-db/src/db/player_hand_type.rs | 17 +- jong-db/src/db/player_or_bot_type.rs | 12 +- jong-db/src/db/player_table.rs | 135 ++++--- jong-db/src/db/player_type.rs | 12 +- jong-db/src/db/rank_type.rs | 10 +- jong-db/src/db/set_ready_reducer.rs | 46 +-- jong-db/src/db/shuffle_deal_reducer.rs | 105 ----- jong-db/src/db/skip_call_reducer.rs | 100 ----- jong-db/src/db/start_game_reducer.rs | 100 ----- jong-db/src/db/suit_type.rs | 13 +- jong-db/src/db/tile_table.rs | 79 ++-- jong-db/src/db/tile_type.rs | 9 +- jong-db/src/db/turn_state_type.rs | 11 +- jong-db/src/db/wall_table.rs | 81 ++-- jong-db/src/db/wind_type.rs | 11 +- 41 files changed, 893 insertions(+), 1673 deletions(-) delete mode 100644 jong-db/src/db/advance_state_timer_table.rs delete mode 100644 jong-db/src/db/advance_state_timer_type.rs delete mode 100644 jong-db/src/db/draw_tile_reducer.rs delete mode 100644 jong-db/src/db/login_or_add_player_reducer.rs delete mode 100644 jong-db/src/db/shuffle_deal_reducer.rs delete mode 100644 jong-db/src/db/skip_call_reducer.rs delete mode 100644 jong-db/src/db/start_game_reducer.rs diff --git a/jong-db/src/db/add_bot_reducer.rs b/jong-db/src/db/add_bot_reducer.rs index 36ed6db..eccf63a 100644 --- a/jong-db/src/db/add_bot_reducer.rs +++ b/jong-db/src/db/add_bot_reducer.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -20,8 +14,8 @@ impl From for super::Reducer { fn from(args: AddBotArgs) -> Self { Self::AddBot { lobby_id: args.lobby_id, -} -} + } + } } impl __sdk::InModule for AddBotArgs { @@ -40,8 +34,7 @@ pub trait add_bot { /// 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 by listening for [`Self::on_add_bot`] callbacks. - fn add_bot(&self, lobby_id: u32, -) -> __sdk::Result<()>; + fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -49,35 +42,39 @@ pub trait add_bot { /// /// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`] /// to cancel the callback. - fn on_add_bot(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> AddBotCallbackId; + fn on_add_bot( + &self, + callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + ) -> AddBotCallbackId; /// Cancel a callback previously registered by [`Self::on_add_bot`], /// causing it not to run in the future. fn remove_on_add_bot(&self, callback: AddBotCallbackId); } impl add_bot for super::RemoteReducers { - fn add_bot(&self, lobby_id: u32, -) -> __sdk::Result<()> { - self.imp.call_reducer("add_bot", AddBotArgs { lobby_id, }) + fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()> { + self.imp.call_reducer("add_bot", AddBotArgs { lobby_id }) } fn on_add_bot( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, ) -> AddBotCallbackId { AddBotCallbackId(self.imp.on_reducer( "add_bot", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::AddBot { - lobby_id, + event: + __sdk::ReducerEvent { + reducer: super::Reducer::AddBot { lobby_id }, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, lobby_id, ) + } = ctx + else { + unreachable!() + }; + callback(ctx, lobby_id) }), )) } @@ -105,4 +102,3 @@ impl set_flags_for_add_bot for super::SetReducerFlags { self.imp.set_call_reducer_flags("add_bot", flags); } } - diff --git a/jong-db/src/db/advance_game_reducer.rs b/jong-db/src/db/advance_game_reducer.rs index fbd576f..a35faad 100644 --- a/jong-db/src/db/advance_game_reducer.rs +++ b/jong-db/src/db/advance_game_reducer.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::game_timer_type::GameTimer; @@ -21,8 +16,8 @@ impl From for super::Reducer { fn from(args: AdvanceGameArgs) -> Self { Self::AdvanceGame { game_timer: args.game_timer, -} -} + } + } } impl __sdk::InModule for AdvanceGameArgs { @@ -41,8 +36,7 @@ pub trait advance_game { /// 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 by listening for [`Self::on_advance_game`] callbacks. - fn advance_game(&self, game_timer: GameTimer, -) -> __sdk::Result<()>; + fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -50,35 +44,40 @@ pub trait advance_game { /// /// The returned [`AdvanceGameCallbackId`] can be passed to [`Self::remove_on_advance_game`] /// to cancel the callback. - fn on_advance_game(&self, callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static) -> AdvanceGameCallbackId; + fn on_advance_game( + &self, + callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static, + ) -> AdvanceGameCallbackId; /// Cancel a callback previously registered by [`Self::on_advance_game`], /// causing it not to run in the future. fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId); } impl advance_game for super::RemoteReducers { - fn advance_game(&self, game_timer: GameTimer, -) -> __sdk::Result<()> { - self.imp.call_reducer("advance_game", AdvanceGameArgs { game_timer, }) + fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> { + self.imp + .call_reducer("advance_game", AdvanceGameArgs { game_timer }) } fn on_advance_game( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static, ) -> AdvanceGameCallbackId { AdvanceGameCallbackId(self.imp.on_reducer( "advance_game", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::AdvanceGame { - game_timer, + event: + __sdk::ReducerEvent { + reducer: super::Reducer::AdvanceGame { game_timer }, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, game_timer, ) + } = ctx + else { + unreachable!() + }; + callback(ctx, game_timer) }), )) } @@ -106,4 +105,3 @@ impl set_flags_for_advance_game for super::SetReducerFlags { self.imp.set_call_reducer_flags("advance_game", flags); } } - diff --git a/jong-db/src/db/advance_state_timer_table.rs b/jong-db/src/db/advance_state_timer_table.rs deleted file mode 100644 index a6096e0..0000000 --- a/jong-db/src/db/advance_state_timer_table.rs +++ /dev/null @@ -1,144 +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::advance_state_timer_type::AdvanceStateTimer; -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -/// Table handle for the table `advance_state_timer`. -/// -/// Obtain a handle from the [`AdvanceStateTimerTableAccess::advance_state_timer`] method on [`super::RemoteTables`], -/// like `ctx.db.advance_state_timer()`. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.advance_state_timer().on_insert(...)`. -pub struct AdvanceStateTimerTableHandle<'ctx> { - imp: __sdk::TableHandle, - ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -#[allow(non_camel_case_types)] -/// Extension trait for access to the table `advance_state_timer`. -/// -/// Implemented for [`super::RemoteTables`]. -pub trait AdvanceStateTimerTableAccess { - #[allow(non_snake_case)] - /// Obtain a [`AdvanceStateTimerTableHandle`], which mediates access to the table `advance_state_timer`. - fn advance_state_timer(&self) -> AdvanceStateTimerTableHandle<'_>; -} - -impl AdvanceStateTimerTableAccess for super::RemoteTables { - fn advance_state_timer(&self) -> AdvanceStateTimerTableHandle<'_> { - AdvanceStateTimerTableHandle { - imp: self - .imp - .get_table::("advance_state_timer"), - ctx: std::marker::PhantomData, - } - } -} - -pub struct AdvanceStateTimerInsertCallbackId(__sdk::CallbackId); -pub struct AdvanceStateTimerDeleteCallbackId(__sdk::CallbackId); - -impl<'ctx> __sdk::Table for AdvanceStateTimerTableHandle<'ctx> { - type Row = AdvanceStateTimer; - type EventContext = super::EventContext; - - fn count(&self) -> u64 { - self.imp.count() - } - fn iter(&self) -> impl Iterator + '_ { - self.imp.iter() - } - - type InsertCallbackId = AdvanceStateTimerInsertCallbackId; - - fn on_insert( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> AdvanceStateTimerInsertCallbackId { - AdvanceStateTimerInsertCallbackId(self.imp.on_insert(Box::new(callback))) - } - - fn remove_on_insert(&self, callback: AdvanceStateTimerInsertCallbackId) { - self.imp.remove_on_insert(callback.0) - } - - type DeleteCallbackId = AdvanceStateTimerDeleteCallbackId; - - fn on_delete( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> AdvanceStateTimerDeleteCallbackId { - AdvanceStateTimerDeleteCallbackId(self.imp.on_delete(Box::new(callback))) - } - - fn remove_on_delete(&self, callback: AdvanceStateTimerDeleteCallbackId) { - self.imp.remove_on_delete(callback.0) - } -} - -#[doc(hidden)] -pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - let _table = client_cache.get_or_make_table::("advance_state_timer"); - _table.add_unique_constraint::("scheduled_id", |row| &row.scheduled_id); -} -pub struct AdvanceStateTimerUpdateCallbackId(__sdk::CallbackId); - -impl<'ctx> __sdk::TableWithPrimaryKey for AdvanceStateTimerTableHandle<'ctx> { - type UpdateCallbackId = AdvanceStateTimerUpdateCallbackId; - - fn on_update( - &self, - callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, - ) -> AdvanceStateTimerUpdateCallbackId { - AdvanceStateTimerUpdateCallbackId(self.imp.on_update(Box::new(callback))) - } - - fn remove_on_update(&self, callback: AdvanceStateTimerUpdateCallbackId) { - self.imp.remove_on_update(callback.0) - } -} - -#[doc(hidden)] -pub(super) fn parse_table_update( - raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, -) -> __sdk::Result<__sdk::TableUpdate> { - __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") - .with_cause(e) - .into() - }) -} - -/// Access to the `scheduled_id` unique index on the table `advance_state_timer`, -/// which allows point queries on the field of the same name -/// via the [`AdvanceStateTimerScheduledIdUnique::find`] method. -/// -/// Users are encouraged not to explicitly reference this type, -/// but to directly chain method calls, -/// like `ctx.db.advance_state_timer().scheduled_id().find(...)`. -pub struct AdvanceStateTimerScheduledIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, -} - -impl<'ctx> AdvanceStateTimerTableHandle<'ctx> { - /// Get a handle on the `scheduled_id` unique index on the table `advance_state_timer`. - pub fn scheduled_id(&self) -> AdvanceStateTimerScheduledIdUnique<'ctx> { - AdvanceStateTimerScheduledIdUnique { - imp: self.imp.get_unique_constraint::("scheduled_id"), - phantom: std::marker::PhantomData, - } - } -} - -impl<'ctx> AdvanceStateTimerScheduledIdUnique<'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) - } -} diff --git a/jong-db/src/db/advance_state_timer_type.rs b/jong-db/src/db/advance_state_timer_type.rs deleted file mode 100644 index 8411902..0000000 --- a/jong-db/src/db/advance_state_timer_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 struct AdvanceStateTimer { - pub scheduled_id: u64, - pub scheduled_at: __sdk::ScheduleAt, - pub lobby_id: u32, -} - -impl __sdk::InModule for AdvanceStateTimer { - type Module = super::RemoteModule; -} diff --git a/jong-db/src/db/bot_table.rs b/jong-db/src/db/bot_table.rs index 25f7dfb..e9379ed 100644 --- a/jong-db/src/db/bot_table.rs +++ b/jong-db/src/db/bot_table.rs @@ -2,15 +2,10 @@ // 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, -}; use super::bot_type::Bot; -use super::turn_state_type::TurnState; 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`. /// @@ -51,8 +46,12 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> { type Row = Bot; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = BotInsertCallbackId; @@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("bot"); + let _table = client_cache.get_or_make_table::("bot"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct BotUpdateCallbackId(__sdk::CallbackId); @@ -104,46 +102,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for BotTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// Access to the `id` unique index on the table `bot`, - /// which allows point queries on the field of the same name - /// via the [`BotIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.bot().id().find(...)`. - pub struct BotIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// Access to the `id` unique index on the table `bot`, +/// which allows point queries on the field of the same name +/// via the [`BotIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.bot().id().find(...)`. +pub struct BotIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> BotTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `bot`. - pub fn id(&self) -> BotIdUnique<'ctx> { - BotIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } +impl<'ctx> BotTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `bot`. + pub fn id(&self) -> BotIdUnique<'ctx> { + BotIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, } + } +} - impl<'ctx> BotIdUnique<'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) - } - } - \ No newline at end of file +impl<'ctx> BotIdUnique<'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) + } +} diff --git a/jong-db/src/db/bot_type.rs b/jong-db/src/db/bot_type.rs index b702466..dcad657 100644 --- a/jong-db/src/db/bot_type.rs +++ b/jong-db/src/db/bot_type.rs @@ -2,15 +2,10 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -use super::turn_state_type::TurnState; 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)] @@ -18,13 +13,11 @@ 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 hand: Vec, + pub pond: Vec, + pub working_tile: Option, } - impl __sdk::InModule for Bot { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/clear_all_reducer.rs b/jong-db/src/db/clear_all_reducer.rs index f33ae7f..5870024 100644 --- a/jong-db/src/db/clear_all_reducer.rs +++ b/jong-db/src/db/clear_all_reducer.rs @@ -2,23 +2,16 @@ // 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, -}; - +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 { - } +pub(super) struct ClearAllArgs {} impl From for super::Reducer { fn from(args: ClearAllArgs) -> Self { Self::ClearAll -} + } } impl __sdk::InModule for ClearAllArgs { @@ -37,7 +30,7 @@ pub trait clear_all { /// 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 by listening for [`Self::on_clear_all`] callbacks. - fn clear_all(&self, ) -> __sdk::Result<()>; + fn clear_all(&self) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `clear_all`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -45,34 +38,39 @@ pub trait clear_all { /// /// The returned [`ClearAllCallbackId`] can be passed to [`Self::remove_on_clear_all`] /// to cancel the callback. - fn on_clear_all(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ClearAllCallbackId; + fn on_clear_all( + &self, + callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, + ) -> ClearAllCallbackId; /// Cancel a callback previously registered by [`Self::on_clear_all`], /// causing it not to run in the future. fn remove_on_clear_all(&self, callback: ClearAllCallbackId); } impl clear_all for super::RemoteReducers { - fn clear_all(&self, ) -> __sdk::Result<()> { - self.imp.call_reducer("clear_all", ClearAllArgs { }) + fn clear_all(&self) -> __sdk::Result<()> { + self.imp.call_reducer("clear_all", ClearAllArgs {}) } fn on_clear_all( &self, - mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, ) -> ClearAllCallbackId { ClearAllCallbackId(self.imp.on_reducer( "clear_all", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::ClearAll { - + event: + __sdk::ReducerEvent { + reducer: super::Reducer::ClearAll {}, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, ) + } = ctx + else { + unreachable!() + }; + callback(ctx) }), )) } @@ -100,4 +98,3 @@ impl set_flags_for_clear_all for super::SetReducerFlags { self.imp.set_call_reducer_flags("clear_all", flags); } } - diff --git a/jong-db/src/db/connect_reducer.rs b/jong-db/src/db/connect_reducer.rs index e82580d..a59a446 100644 --- a/jong-db/src/db/connect_reducer.rs +++ b/jong-db/src/db/connect_reducer.rs @@ -2,23 +2,16 @@ // 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, -}; - +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 ConnectArgs { - } +pub(super) struct ConnectArgs {} impl From for super::Reducer { fn from(args: ConnectArgs) -> Self { Self::Connect -} + } } impl __sdk::InModule for ConnectArgs { @@ -37,7 +30,7 @@ pub trait connect { /// 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 by listening for [`Self::on_connect`] callbacks. - fn connect(&self, ) -> __sdk::Result<()>; + fn connect(&self) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `connect`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -45,34 +38,39 @@ pub trait connect { /// /// The returned [`ConnectCallbackId`] can be passed to [`Self::remove_on_connect`] /// to cancel the callback. - fn on_connect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ConnectCallbackId; + fn on_connect( + &self, + callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, + ) -> ConnectCallbackId; /// Cancel a callback previously registered by [`Self::on_connect`], /// causing it not to run in the future. fn remove_on_connect(&self, callback: ConnectCallbackId); } impl connect for super::RemoteReducers { - fn connect(&self, ) -> __sdk::Result<()> { - self.imp.call_reducer("connect", ConnectArgs { }) + fn connect(&self) -> __sdk::Result<()> { + self.imp.call_reducer("connect", ConnectArgs {}) } fn on_connect( &self, - mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, ) -> ConnectCallbackId { ConnectCallbackId(self.imp.on_reducer( "connect", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::Connect { - + event: + __sdk::ReducerEvent { + reducer: super::Reducer::Connect {}, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, ) + } = ctx + else { + unreachable!() + }; + callback(ctx) }), )) } @@ -100,4 +98,3 @@ impl set_flags_for_connect for super::SetReducerFlags { self.imp.set_call_reducer_flags("connect", flags); } } - diff --git a/jong-db/src/db/db_tile_type.rs b/jong-db/src/db/db_tile_type.rs index 94cb0a9..cf5c736 100644 --- a/jong-db/src/db/db_tile_type.rs +++ b/jong-db/src/db/db_tile_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::tile_type::Tile; @@ -18,8 +13,6 @@ pub struct DbTile { pub tile: Tile, } - impl __sdk::InModule for DbTile { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/db_wall_type.rs b/jong-db/src/db/db_wall_type.rs index 7bb7ba5..20688c7 100644 --- a/jong-db/src/db/db_wall_type.rs +++ b/jong-db/src/db/db_wall_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::db_tile_type::DbTile; @@ -15,11 +10,9 @@ use super::db_tile_type::DbTile; #[sats(crate = __lib)] pub struct DbWall { pub lobby_id: u32, - pub tiles: Vec::, + pub tiles: Vec, } - impl __sdk::InModule for DbWall { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/discard_tile_reducer.rs b/jong-db/src/db/discard_tile_reducer.rs index 204877f..c3bcb15 100644 --- a/jong-db/src/db/discard_tile_reducer.rs +++ b/jong-db/src/db/discard_tile_reducer.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -20,8 +14,8 @@ impl From for super::Reducer { fn from(args: DiscardTileArgs) -> Self { Self::DiscardTile { tile_id: args.tile_id, -} -} + } + } } impl __sdk::InModule for DiscardTileArgs { @@ -40,8 +34,7 @@ pub trait discard_tile { /// 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 by listening for [`Self::on_discard_tile`] callbacks. - fn discard_tile(&self, tile_id: u32, -) -> __sdk::Result<()>; + fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `discard_tile`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -49,35 +42,40 @@ pub trait discard_tile { /// /// The returned [`DiscardTileCallbackId`] can be passed to [`Self::remove_on_discard_tile`] /// to cancel the callback. - fn on_discard_tile(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> DiscardTileCallbackId; + fn on_discard_tile( + &self, + callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + ) -> DiscardTileCallbackId; /// Cancel a callback previously registered by [`Self::on_discard_tile`], /// causing it not to run in the future. fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId); } impl discard_tile for super::RemoteReducers { - fn discard_tile(&self, tile_id: u32, -) -> __sdk::Result<()> { - self.imp.call_reducer("discard_tile", DiscardTileArgs { tile_id, }) + fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()> { + self.imp + .call_reducer("discard_tile", DiscardTileArgs { tile_id }) } fn on_discard_tile( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, ) -> DiscardTileCallbackId { DiscardTileCallbackId(self.imp.on_reducer( "discard_tile", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::DiscardTile { - tile_id, + event: + __sdk::ReducerEvent { + reducer: super::Reducer::DiscardTile { tile_id }, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, tile_id, ) + } = ctx + else { + unreachable!() + }; + callback(ctx, tile_id) }), )) } @@ -105,4 +103,3 @@ impl set_flags_for_discard_tile for super::SetReducerFlags { self.imp.set_call_reducer_flags("discard_tile", flags); } } - diff --git a/jong-db/src/db/disconnect_reducer.rs b/jong-db/src/db/disconnect_reducer.rs index 795b9ec..026d4b1 100644 --- a/jong-db/src/db/disconnect_reducer.rs +++ b/jong-db/src/db/disconnect_reducer.rs @@ -2,23 +2,16 @@ // 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, -}; - +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 DisconnectArgs { - } +pub(super) struct DisconnectArgs {} impl From for super::Reducer { fn from(args: DisconnectArgs) -> Self { Self::Disconnect -} + } } impl __sdk::InModule for DisconnectArgs { @@ -37,7 +30,7 @@ pub trait disconnect { /// 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 by listening for [`Self::on_disconnect`] callbacks. - fn disconnect(&self, ) -> __sdk::Result<()>; + fn disconnect(&self) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `disconnect`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -45,34 +38,39 @@ pub trait disconnect { /// /// The returned [`DisconnectCallbackId`] can be passed to [`Self::remove_on_disconnect`] /// to cancel the callback. - fn on_disconnect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> DisconnectCallbackId; + fn on_disconnect( + &self, + callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, + ) -> DisconnectCallbackId; /// Cancel a callback previously registered by [`Self::on_disconnect`], /// causing it not to run in the future. fn remove_on_disconnect(&self, callback: DisconnectCallbackId); } impl disconnect for super::RemoteReducers { - fn disconnect(&self, ) -> __sdk::Result<()> { - self.imp.call_reducer("disconnect", DisconnectArgs { }) + fn disconnect(&self) -> __sdk::Result<()> { + self.imp.call_reducer("disconnect", DisconnectArgs {}) } fn on_disconnect( &self, - mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, ) -> DisconnectCallbackId { DisconnectCallbackId(self.imp.on_reducer( "disconnect", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::Disconnect { - + event: + __sdk::ReducerEvent { + reducer: super::Reducer::Disconnect {}, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, ) + } = ctx + else { + unreachable!() + }; + callback(ctx) }), )) } @@ -100,4 +98,3 @@ impl set_flags_for_disconnect for super::SetReducerFlags { self.imp.set_call_reducer_flags("disconnect", flags); } } - diff --git a/jong-db/src/db/dragon_type.rs b/jong-db/src/db/dragon_type.rs index 58733f5..4b954b1 100644 --- a/jong-db/src/db/dragon_type.rs +++ b/jong-db/src/db/dragon_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -18,12 +13,8 @@ pub enum Dragon { Hatsu, Chun, - } - - impl __sdk::InModule for Dragon { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/draw_tile_reducer.rs b/jong-db/src/db/draw_tile_reducer.rs deleted file mode 100644 index daed29a..0000000 --- a/jong-db/src/db/draw_tile_reducer.rs +++ /dev/null @@ -1,100 +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 DrawTileArgs {} - -impl From for super::Reducer { - fn from(args: DrawTileArgs) -> Self { - Self::DrawTile - } -} - -impl __sdk::InModule for DrawTileArgs { - type Module = super::RemoteModule; -} - -pub struct DrawTileCallbackId(__sdk::CallbackId); - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `draw_tile`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait draw_tile { - /// Request that the remote module invoke the reducer `draw_tile` 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 its status can be observed by listening for [`Self::on_draw_tile`] callbacks. - fn draw_tile(&self) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `draw_tile`. - /// - /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] - /// to determine the reducer's status. - /// - /// The returned [`DrawTileCallbackId`] can be passed to [`Self::remove_on_draw_tile`] - /// to cancel the callback. - fn on_draw_tile( - &self, - callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> DrawTileCallbackId; - /// Cancel a callback previously registered by [`Self::on_draw_tile`], - /// causing it not to run in the future. - fn remove_on_draw_tile(&self, callback: DrawTileCallbackId); -} - -impl draw_tile for super::RemoteReducers { - fn draw_tile(&self) -> __sdk::Result<()> { - self.imp.call_reducer("draw_tile", DrawTileArgs {}) - } - fn on_draw_tile( - &self, - mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> DrawTileCallbackId { - DrawTileCallbackId(self.imp.on_reducer( - "draw_tile", - Box::new(move |ctx: &super::ReducerEventContext| { - #[allow(irrefutable_let_patterns)] - let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::DrawTile {}, - .. - }, - .. - } = ctx - else { - unreachable!() - }; - callback(ctx) - }), - )) - } - fn remove_on_draw_tile(&self, callback: DrawTileCallbackId) { - self.imp.remove_on_reducer("draw_tile", callback.0) - } -} - -#[allow(non_camel_case_types)] -#[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `draw_tile`. -/// -/// Implemented for [`super::SetReducerFlags`]. -/// -/// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_draw_tile { - /// Set the call-reducer flags for the reducer `draw_tile` to `flags`. - /// - /// This type is currently unstable and may be removed without a major version bump. - fn draw_tile(&self, flags: __ws::CallReducerFlags); -} - -impl set_flags_for_draw_tile for super::SetReducerFlags { - fn draw_tile(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("draw_tile", flags); - } -} diff --git a/jong-db/src/db/game_state_type.rs b/jong-db/src/db/game_state_type.rs index 7bb60cb..b8cafa4 100644 --- a/jong-db/src/db/game_state_type.rs +++ b/jong-db/src/db/game_state_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -24,12 +19,8 @@ pub enum GameState { Play, Exit, - } - - impl __sdk::InModule for GameState { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/game_timer_table.rs b/jong-db/src/db/game_timer_table.rs index db3138b..58bdfe0 100644 --- a/jong-db/src/db/game_timer_table.rs +++ b/jong-db/src/db/game_timer_table.rs @@ -2,13 +2,8 @@ // 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, -}; use super::game_timer_type::GameTimer; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `game_timer`. /// @@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> { type Row = GameTimer; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = GameTimerInsertCallbackId; @@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("game_timer"); + let _table = client_cache.get_or_make_table::("game_timer"); _table.add_unique_constraint::("id", |row| &row.id); _table.add_unique_constraint::("lobby_id", |row| &row.lobby_id); } @@ -103,76 +101,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// 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>, - } +/// 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> 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. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.game_timer().lobby_id().find(...)`. - pub struct GameTimerLobbyIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +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) + } +} - impl<'ctx> GameTimerTableHandle<'ctx> { - /// Get a handle on the `lobby_id` unique index on the table `game_timer`. - pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> { - GameTimerLobbyIdUnique { - imp: self.imp.get_unique_constraint::("lobby_id"), - phantom: std::marker::PhantomData, - } - } - } +/// 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. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.game_timer().lobby_id().find(...)`. +pub struct GameTimerLobbyIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - 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 { - self.imp.find(col_val) - } +impl<'ctx> GameTimerTableHandle<'ctx> { + /// Get a handle on the `lobby_id` unique index on the table `game_timer`. + pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> { + GameTimerLobbyIdUnique { + imp: self.imp.get_unique_constraint::("lobby_id"), + phantom: std::marker::PhantomData, } - \ No newline at end of file + } +} + +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 { + self.imp.find(col_val) + } +} diff --git a/jong-db/src/db/game_timer_type.rs b/jong-db/src/db/game_timer_type.rs index 19af105..cefd735 100644 --- a/jong-db/src/db/game_timer_type.rs +++ b/jong-db/src/db/game_timer_type.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -18,8 +12,6 @@ pub struct GameTimer { pub scheduled_at: __sdk::ScheduleAt, } - impl __sdk::InModule for GameTimer { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/join_or_create_lobby_reducer.rs b/jong-db/src/db/join_or_create_lobby_reducer.rs index c9aec78..2545903 100644 --- a/jong-db/src/db/join_or_create_lobby_reducer.rs +++ b/jong-db/src/db/join_or_create_lobby_reducer.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -20,8 +14,8 @@ impl From for super::Reducer { fn from(args: JoinOrCreateLobbyArgs) -> Self { Self::JoinOrCreateLobby { lobby_id: args.lobby_id, -} -} + } + } } impl __sdk::InModule for JoinOrCreateLobbyArgs { @@ -40,8 +34,7 @@ pub trait join_or_create_lobby { /// 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 by listening for [`Self::on_join_or_create_lobby`] callbacks. - fn join_or_create_lobby(&self, lobby_id: u32, -) -> __sdk::Result<()>; + fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -49,40 +42,46 @@ pub trait join_or_create_lobby { /// /// The returned [`JoinOrCreateLobbyCallbackId`] can be passed to [`Self::remove_on_join_or_create_lobby`] /// to cancel the callback. - fn on_join_or_create_lobby(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> JoinOrCreateLobbyCallbackId; + fn on_join_or_create_lobby( + &self, + callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, + ) -> JoinOrCreateLobbyCallbackId; /// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`], /// causing it not to run in the future. fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId); } impl join_or_create_lobby for super::RemoteReducers { - fn join_or_create_lobby(&self, lobby_id: u32, -) -> __sdk::Result<()> { - self.imp.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id, }) + fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> { + self.imp + .call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id }) } fn on_join_or_create_lobby( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, ) -> JoinOrCreateLobbyCallbackId { JoinOrCreateLobbyCallbackId(self.imp.on_reducer( "join_or_create_lobby", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::JoinOrCreateLobby { - lobby_id, + event: + __sdk::ReducerEvent { + reducer: super::Reducer::JoinOrCreateLobby { lobby_id }, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, lobby_id, ) + } = ctx + else { + unreachable!() + }; + callback(ctx, lobby_id) }), )) } fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) { - self.imp.remove_on_reducer("join_or_create_lobby", callback.0) + self.imp + .remove_on_reducer("join_or_create_lobby", callback.0) } } @@ -102,7 +101,7 @@ pub trait set_flags_for_join_or_create_lobby { impl set_flags_for_join_or_create_lobby for super::SetReducerFlags { fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("join_or_create_lobby", flags); + self.imp + .set_call_reducer_flags("join_or_create_lobby", flags); } } - diff --git a/jong-db/src/db/lobby_table.rs b/jong-db/src/db/lobby_table.rs index e403a30..962b676 100644 --- a/jong-db/src/db/lobby_table.rs +++ b/jong-db/src/db/lobby_table.rs @@ -2,15 +2,10 @@ // 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, -}; +use super::game_state_type::GameState; use super::lobby_type::Lobby; use super::player_or_bot_type::PlayerOrBot; -use super::game_state_type::GameState; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `lobby`. /// @@ -51,8 +46,12 @@ 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 + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = LobbyInsertCallbackId; @@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("lobby"); + let _table = client_cache.get_or_make_table::("lobby"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct LobbyUpdateCallbackId(__sdk::CallbackId); @@ -104,46 +102,43 @@ 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> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "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, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// 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, + 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::("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::("id"), + phantom: std::marker::PhantomData, } + } +} - 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 { - self.imp.find(col_val) - } - } - \ No newline at end of file +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 { + self.imp.find(col_val) + } +} diff --git a/jong-db/src/db/lobby_type.rs b/jong-db/src/db/lobby_type.rs index 34621a1..6fca7de 100644 --- a/jong-db/src/db/lobby_type.rs +++ b/jong-db/src/db/lobby_type.rs @@ -2,28 +2,21 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -use super::player_or_bot_type::PlayerOrBot; 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, } - impl __sdk::InModule for Lobby { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/logged_out_player_table.rs b/jong-db/src/db/logged_out_player_table.rs index a66b89e..aeaa8a2 100644 --- a/jong-db/src/db/logged_out_player_table.rs +++ b/jong-db/src/db/logged_out_player_table.rs @@ -2,13 +2,8 @@ // 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, -}; use super::player_type::Player; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `logged_out_player`. /// @@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for LoggedOutPlayerTableHandle<'ctx> { type Row = Player; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = LoggedOutPlayerInsertCallbackId; @@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for LoggedOutPlayerTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("logged_out_player"); + let _table = client_cache.get_or_make_table::("logged_out_player"); _table.add_unique_constraint::("id", |row| &row.id); _table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity); } @@ -103,76 +101,75 @@ impl<'ctx> __sdk::TableWithPrimaryKey for LoggedOutPlayerTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// Access to the `id` unique index on the table `logged_out_player`, - /// which allows point queries on the field of the same name - /// via the [`LoggedOutPlayerIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.logged_out_player().id().find(...)`. - pub struct LoggedOutPlayerIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// Access to the `id` unique index on the table `logged_out_player`, +/// which allows point queries on the field of the same name +/// via the [`LoggedOutPlayerIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.logged_out_player().id().find(...)`. +pub struct LoggedOutPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `logged_out_player`. - pub fn id(&self) -> LoggedOutPlayerIdUnique<'ctx> { - LoggedOutPlayerIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } +impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `logged_out_player`. + pub fn id(&self) -> LoggedOutPlayerIdUnique<'ctx> { + LoggedOutPlayerIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, } + } +} - impl<'ctx> LoggedOutPlayerIdUnique<'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 `logged_out_player`, - /// which allows point queries on the field of the same name - /// via the [`LoggedOutPlayerIdentityUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.logged_out_player().identity().find(...)`. - pub struct LoggedOutPlayerIdentityUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +impl<'ctx> LoggedOutPlayerIdUnique<'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) + } +} - impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { - /// Get a handle on the `identity` unique index on the table `logged_out_player`. - pub fn identity(&self) -> LoggedOutPlayerIdentityUnique<'ctx> { - LoggedOutPlayerIdentityUnique { - imp: self.imp.get_unique_constraint::<__sdk::Identity>("identity"), - phantom: std::marker::PhantomData, - } - } - } +/// Access to the `identity` unique index on the table `logged_out_player`, +/// which allows point queries on the field of the same name +/// via the [`LoggedOutPlayerIdentityUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.logged_out_player().identity().find(...)`. +pub struct LoggedOutPlayerIdentityUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> LoggedOutPlayerIdentityUnique<'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) - } +impl<'ctx> LoggedOutPlayerTableHandle<'ctx> { + /// Get a handle on the `identity` unique index on the table `logged_out_player`. + pub fn identity(&self) -> LoggedOutPlayerIdentityUnique<'ctx> { + LoggedOutPlayerIdentityUnique { + imp: self + .imp + .get_unique_constraint::<__sdk::Identity>("identity"), + phantom: std::marker::PhantomData, } - \ No newline at end of file + } +} + +impl<'ctx> LoggedOutPlayerIdentityUnique<'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) + } +} diff --git a/jong-db/src/db/login_or_add_player_reducer.rs b/jong-db/src/db/login_or_add_player_reducer.rs deleted file mode 100644 index f94c20f..0000000 --- a/jong-db/src/db/login_or_add_player_reducer.rs +++ /dev/null @@ -1,103 +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 LoginOrAddPlayerArgs {} - -impl From for super::Reducer { - fn from(args: LoginOrAddPlayerArgs) -> Self { - Self::LoginOrAddPlayer - } -} - -impl __sdk::InModule for LoginOrAddPlayerArgs { - type Module = super::RemoteModule; -} - -pub struct LoginOrAddPlayerCallbackId(__sdk::CallbackId); - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `login_or_add_player`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait login_or_add_player { - /// Request that the remote module invoke the reducer `login_or_add_player` 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 its status can be observed by listening for [`Self::on_login_or_add_player`] callbacks. - fn login_or_add_player(&self) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `login_or_add_player`. - /// - /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] - /// to determine the reducer's status. - /// - /// The returned [`LoginOrAddPlayerCallbackId`] can be passed to [`Self::remove_on_login_or_add_player`] - /// to cancel the callback. - fn on_login_or_add_player( - &self, - callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> LoginOrAddPlayerCallbackId; - /// Cancel a callback previously registered by [`Self::on_login_or_add_player`], - /// causing it not to run in the future. - fn remove_on_login_or_add_player(&self, callback: LoginOrAddPlayerCallbackId); -} - -impl login_or_add_player for super::RemoteReducers { - fn login_or_add_player(&self) -> __sdk::Result<()> { - self.imp - .call_reducer("login_or_add_player", LoginOrAddPlayerArgs {}) - } - fn on_login_or_add_player( - &self, - mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> LoginOrAddPlayerCallbackId { - LoginOrAddPlayerCallbackId(self.imp.on_reducer( - "login_or_add_player", - Box::new(move |ctx: &super::ReducerEventContext| { - #[allow(irrefutable_let_patterns)] - let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::LoginOrAddPlayer {}, - .. - }, - .. - } = ctx - else { - unreachable!() - }; - callback(ctx) - }), - )) - } - fn remove_on_login_or_add_player(&self, callback: LoginOrAddPlayerCallbackId) { - self.imp - .remove_on_reducer("login_or_add_player", callback.0) - } -} - -#[allow(non_camel_case_types)] -#[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `login_or_add_player`. -/// -/// Implemented for [`super::SetReducerFlags`]. -/// -/// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_login_or_add_player { - /// Set the call-reducer flags for the reducer `login_or_add_player` to `flags`. - /// - /// This type is currently unstable and may be removed without a major version bump. - fn login_or_add_player(&self, flags: __ws::CallReducerFlags); -} - -impl set_flags_for_login_or_add_player for super::SetReducerFlags { - fn login_or_add_player(&self, flags: __ws::CallReducerFlags) { - self.imp - .set_call_reducer_flags("login_or_add_player", flags); - } -} diff --git a/jong-db/src/db/mod.rs b/jong-db/src/db/mod.rs index 4d46508..de00af9 100644 --- a/jong-db/src/db/mod.rs +++ b/jong-db/src/db/mod.rs @@ -4,80 +4,77 @@ // This was generated using spacetimedb cli version 1.11.3 (commit 02449737ca3b29e7e39679fccbef541a50f32094). #![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{ - self as __sdk, - __lib, - __sats, - __ws, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -pub mod bot_type; -pub mod db_tile_type; -pub mod db_wall_type; -pub mod dragon_type; -pub mod game_state_type; -pub mod game_timer_type; -pub mod lobby_type; -pub mod player_type; -pub mod player_clock_type; -pub mod player_hand_type; -pub mod player_or_bot_type; -pub mod rank_type; -pub mod suit_type; -pub mod tile_type; -pub mod turn_state_type; -pub mod wind_type; 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 connect_reducer; +pub mod db_tile_type; +pub mod db_wall_type; pub mod discard_tile_reducer; pub mod disconnect_reducer; -pub mod join_or_create_lobby_reducer; -pub mod set_ready_reducer; -pub mod bot_table; +pub mod dragon_type; +pub mod game_state_type; pub mod game_timer_table; +pub mod game_timer_type; +pub mod join_or_create_lobby_reducer; pub mod lobby_table; +pub mod lobby_type; pub mod logged_out_player_table; -pub mod player_table; pub mod player_clock_table; +pub mod player_clock_type; pub mod player_hand_table; +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_table; +pub mod tile_type; +pub mod turn_state_type; pub mod wall_table; +pub mod wind_type; -pub use bot_type::Bot; -pub use db_tile_type::DbTile; -pub use db_wall_type::DbWall; -pub use dragon_type::Dragon; -pub use game_state_type::GameState; -pub use game_timer_type::GameTimer; -pub use lobby_type::Lobby; -pub use player_type::Player; -pub use player_clock_type::PlayerClock; -pub use player_hand_type::PlayerHand; -pub use player_or_bot_type::PlayerOrBot; -pub use rank_type::Rank; -pub use suit_type::Suit; -pub use tile_type::Tile; -pub use turn_state_type::TurnState; -pub use wind_type::Wind; -pub use bot_table::*; -pub use game_timer_table::*; -pub use lobby_table::*; -pub use logged_out_player_table::*; -pub use player_table::*; -pub use player_clock_table::*; -pub use player_hand_table::*; -pub use tile_table::*; -pub use wall_table::*; pub use add_bot_reducer::{add_bot, set_flags_for_add_bot, AddBotCallbackId}; pub use advance_game_reducer::{advance_game, set_flags_for_advance_game, AdvanceGameCallbackId}; +pub use bot_table::*; +pub use bot_type::Bot; pub use clear_all_reducer::{clear_all, set_flags_for_clear_all, ClearAllCallbackId}; pub use connect_reducer::{connect, set_flags_for_connect, ConnectCallbackId}; +pub use db_tile_type::DbTile; +pub use db_wall_type::DbWall; pub use discard_tile_reducer::{discard_tile, set_flags_for_discard_tile, DiscardTileCallbackId}; pub use disconnect_reducer::{disconnect, set_flags_for_disconnect, DisconnectCallbackId}; -pub use join_or_create_lobby_reducer::{join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId}; -pub use set_ready_reducer::{set_ready, set_flags_for_set_ready, SetReadyCallbackId}; +pub use dragon_type::Dragon; +pub use game_state_type::GameState; +pub use game_timer_table::*; +pub use game_timer_type::GameTimer; +pub use join_or_create_lobby_reducer::{ + join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId, +}; +pub use lobby_table::*; +pub use lobby_type::Lobby; +pub use logged_out_player_table::*; +pub use player_clock_table::*; +pub use player_clock_type::PlayerClock; +pub use player_hand_table::*; +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_flags_for_set_ready, set_ready, SetReadyCallbackId}; +pub use suit_type::Suit; +pub use tile_table::*; +pub use tile_type::Tile; +pub use turn_state_type::TurnState; +pub use wall_table::*; +pub use wind_type::Wind; #[derive(Clone, PartialEq, Debug)] @@ -87,27 +84,16 @@ pub use set_ready_reducer::{set_ready, set_flags_for_set_ready, SetReadyCallback /// to indicate which reducer caused the event. pub enum Reducer { - AddBot { - lobby_id: u32, -} , - AdvanceGame { - game_timer: GameTimer, -} , - ClearAll , - Connect , - DiscardTile { - tile_id: u32, -} , - Disconnect , - JoinOrCreateLobby { - lobby_id: u32, -} , - SetReady { - ready: bool, -} , + AddBot { lobby_id: u32 }, + AdvanceGame { game_timer: GameTimer }, + ClearAll, + Connect, + DiscardTile { tile_id: u32 }, + Disconnect, + JoinOrCreateLobby { lobby_id: u32 }, + SetReady { ready: bool }, } - impl __sdk::InModule for Reducer { type Module = RemoteModule; } @@ -115,7 +101,7 @@ impl __sdk::InModule for Reducer { impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::AddBot { .. } => "add_bot", + Reducer::AddBot { .. } => "add_bot", Reducer::AdvanceGame { .. } => "advance_game", Reducer::ClearAll => "clear_all", Reducer::Connect => "connect", @@ -124,31 +110,77 @@ impl __sdk::Reducer for Reducer { Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby", Reducer::SetReady { .. } => "set_ready", _ => unreachable!(), -} -} + } + } } impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { - type Error = __sdk::Error; -fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result { + type Error = __sdk::Error; + fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result { match &value.reducer_name[..] { - "add_bot" => Ok(__sdk::parse_reducer_args::("add_bot", &value.args)?.into()), - "advance_game" => Ok(__sdk::parse_reducer_args::("advance_game", &value.args)?.into()), - "clear_all" => Ok(__sdk::parse_reducer_args::("clear_all", &value.args)?.into()), - "connect" => Ok(__sdk::parse_reducer_args::("connect", &value.args)?.into()), - "discard_tile" => Ok(__sdk::parse_reducer_args::("discard_tile", &value.args)?.into()), - "disconnect" => Ok(__sdk::parse_reducer_args::("disconnect", &value.args)?.into()), - "join_or_create_lobby" => Ok(__sdk::parse_reducer_args::("join_or_create_lobby", &value.args)?.into()), - "set_ready" => Ok(__sdk::parse_reducer_args::("set_ready", &value.args)?.into()), - unknown => Err(__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo").into()), -} -} + "add_bot" => Ok(__sdk::parse_reducer_args::( + "add_bot", + &value.args, + )? + .into()), + "advance_game" => Ok( + __sdk::parse_reducer_args::( + "advance_game", + &value.args, + )? + .into(), + ), + "clear_all" => Ok( + __sdk::parse_reducer_args::( + "clear_all", + &value.args, + )? + .into(), + ), + "connect" => Ok(__sdk::parse_reducer_args::( + "connect", + &value.args, + )? + .into()), + "discard_tile" => Ok( + __sdk::parse_reducer_args::( + "discard_tile", + &value.args, + )? + .into(), + ), + "disconnect" => Ok( + __sdk::parse_reducer_args::( + "disconnect", + &value.args, + )? + .into(), + ), + "join_or_create_lobby" => Ok(__sdk::parse_reducer_args::< + join_or_create_lobby_reducer::JoinOrCreateLobbyArgs, + >("join_or_create_lobby", &value.args)? + .into()), + "set_ready" => Ok( + __sdk::parse_reducer_args::( + "set_ready", + &value.args, + )? + .into(), + ), + unknown => { + Err( + __sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo") + .into(), + ) + } + } + } } #[derive(Default)] #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - bot: __sdk::TableUpdate, + bot: __sdk::TableUpdate, game_timer: __sdk::TableUpdate, lobby: __sdk::TableUpdate, logged_out_player: __sdk::TableUpdate, @@ -159,30 +191,47 @@ pub struct DbUpdate { wall: __sdk::TableUpdate, } - impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { type Error = __sdk::Error; fn try_from(raw: __ws::DatabaseUpdate<__ws::BsatnFormat>) -> Result { let mut db_update = DbUpdate::default(); for table_update in raw.tables { match &table_update.table_name[..] { - - "bot" => db_update.bot.append(bot_table::parse_table_update(table_update)?), - "game_timer" => db_update.game_timer.append(game_timer_table::parse_table_update(table_update)?), - "lobby" => db_update.lobby.append(lobby_table::parse_table_update(table_update)?), - "logged_out_player" => db_update.logged_out_player.append(logged_out_player_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_hand" => db_update.player_hand.append(player_hand_table::parse_table_update(table_update)?), - "tile" => db_update.tile.append(tile_table::parse_table_update(table_update)?), - "wall" => db_update.wall.append(wall_table::parse_table_update(table_update)?), + "bot" => db_update + .bot + .append(bot_table::parse_table_update(table_update)?), + "game_timer" => db_update + .game_timer + .append(game_timer_table::parse_table_update(table_update)?), + "lobby" => db_update + .lobby + .append(lobby_table::parse_table_update(table_update)?), + "logged_out_player" => db_update + .logged_out_player + .append(logged_out_player_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_hand" => db_update + .player_hand + .append(player_hand_table::parse_table_update(table_update)?), + "tile" => db_update + .tile + .append(tile_table::parse_table_update(table_update)?), + "wall" => db_update + .wall + .append(wall_table::parse_table_update(table_update)?), unknown => { return Err(__sdk::InternalError::unknown_name( "table", unknown, "DatabaseUpdate", - ).into()); + ) + .into()); } } } @@ -195,28 +244,49 @@ impl __sdk::InModule for DbUpdate { } impl __sdk::DbUpdate for DbUpdate { - fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache) -> AppliedDiff<'_> { - let mut diff = AppliedDiff::default(); - - diff.bot = cache.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); - diff.lobby = cache.apply_diff_to_table::("lobby", &self.lobby).with_updates_by_pk(|row| &row.id); - diff.logged_out_player = cache.apply_diff_to_table::("logged_out_player", &self.logged_out_player).with_updates_by_pk(|row| &row.identity); - 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.id); - diff.player_hand = cache.apply_diff_to_table::("player_hand", &self.player_hand).with_updates_by_pk(|row| &row.id); - diff.tile = cache.apply_diff_to_table::("tile", &self.tile).with_updates_by_pk(|row| &row.id); - diff.wall = cache.apply_diff_to_table::("wall", &self.wall).with_updates_by_pk(|row| &row.lobby_id); + fn apply_to_client_cache( + &self, + cache: &mut __sdk::ClientCache, + ) -> AppliedDiff<'_> { + let mut diff = AppliedDiff::default(); - diff - } + diff.bot = cache + .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); + diff.lobby = cache + .apply_diff_to_table::("lobby", &self.lobby) + .with_updates_by_pk(|row| &row.id); + diff.logged_out_player = cache + .apply_diff_to_table::("logged_out_player", &self.logged_out_player) + .with_updates_by_pk(|row| &row.identity); + 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.id); + diff.player_hand = cache + .apply_diff_to_table::("player_hand", &self.player_hand) + .with_updates_by_pk(|row| &row.id); + diff.tile = cache + .apply_diff_to_table::("tile", &self.tile) + .with_updates_by_pk(|row| &row.id); + diff.wall = cache + .apply_diff_to_table::("wall", &self.wall) + .with_updates_by_pk(|row| &row.lobby_id); + + diff + } } #[derive(Default)] #[allow(non_snake_case)] #[doc(hidden)] pub struct AppliedDiff<'r> { - bot: __sdk::TableAppliedDiff<'r, Bot>, + bot: __sdk::TableAppliedDiff<'r, Bot>, game_timer: __sdk::TableAppliedDiff<'r, GameTimer>, lobby: __sdk::TableAppliedDiff<'r, Lobby>, logged_out_player: __sdk::TableAppliedDiff<'r, Player>, @@ -228,25 +298,35 @@ pub struct AppliedDiff<'r> { __unused: std::marker::PhantomData<&'r ()>, } - impl __sdk::InModule for AppliedDiff<'_> { type Module = RemoteModule; } impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> { - fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks) { - callbacks.invoke_table_row_callbacks::("bot", &self.bot, event); + fn invoke_row_callbacks( + &self, + event: &EventContext, + 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::("lobby", &self.lobby, event); - callbacks.invoke_table_row_callbacks::("logged_out_player", &self.logged_out_player, event); + callbacks.invoke_table_row_callbacks::( + "logged_out_player", + &self.logged_out_player, + 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_clock", + &self.player_clock, + event, + ); callbacks.invoke_table_row_callbacks::("player_hand", &self.player_hand, event); callbacks.invoke_table_row_callbacks::("tile", &self.tile, event); callbacks.invoke_table_row_callbacks::("wall", &self.wall, event); + } } -} - #[doc(hidden)] pub struct RemoteModule; @@ -499,7 +579,6 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle { fn unsubscribe(self) -> __sdk::Result<()> { self.imp.unsubscribe_then(None) } - } /// Alias trait for a [`__sdk::DbContext`] connected to this module, @@ -507,19 +586,25 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle { /// /// Users can use this trait as a boundary on definitions which should accept /// either a [`DbConnection`] or an [`EventContext`] and operate on either. -pub trait RemoteDbContext: __sdk::DbContext< +pub trait RemoteDbContext: + __sdk::DbContext< DbView = RemoteTables, Reducers = RemoteReducers, SetReducerFlags = SetReducerFlags, SubscriptionBuilder = __sdk::SubscriptionBuilder, -> {} -impl, ->> RemoteDbContext for Ctx {} - +> +{ +} +impl< + Ctx: __sdk::DbContext< + DbView = RemoteTables, + Reducers = RemoteReducers, + SetReducerFlags = SetReducerFlags, + SubscriptionBuilder = __sdk::SubscriptionBuilder, + >, + > RemoteDbContext for Ctx +{ +} /// An [`__sdk::DbContext`] augmented with a [`__sdk::Event`], /// passed to [`__sdk::Table::on_insert`], [`__sdk::Table::on_delete`] and [`__sdk::TableWithPrimaryKey::on_update`] callbacks. @@ -944,7 +1029,6 @@ impl __sdk::DbContext for ErrorContext { impl __sdk::ErrorContext for ErrorContext {} impl __sdk::SpacetimeModule for RemoteModule { - type DbConnection = DbConnection; type EventContext = EventContext; type ReducerEventContext = ReducerEventContext; @@ -959,8 +1043,8 @@ impl __sdk::SpacetimeModule for RemoteModule { type AppliedDiff<'r> = AppliedDiff<'r>; type SubscriptionHandle = SubscriptionHandle; -fn register_tables(client_cache: &mut __sdk::ClientCache) { - bot_table::register_table(client_cache); + fn register_tables(client_cache: &mut __sdk::ClientCache) { + bot_table::register_table(client_cache); game_timer_table::register_table(client_cache); lobby_table::register_table(client_cache); logged_out_player_table::register_table(client_cache); @@ -969,5 +1053,5 @@ fn register_tables(client_cache: &mut __sdk::ClientCache) { player_hand_table::register_table(client_cache); tile_table::register_table(client_cache); wall_table::register_table(client_cache); -} + } } diff --git a/jong-db/src/db/player_clock_table.rs b/jong-db/src/db/player_clock_table.rs index 41dc148..551f521 100644 --- a/jong-db/src/db/player_clock_table.rs +++ b/jong-db/src/db/player_clock_table.rs @@ -2,13 +2,8 @@ // 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, -}; use super::player_clock_type::PlayerClock; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `player_clock`. /// @@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> { type Row = PlayerClock; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = PlayerClockInsertCallbackId; @@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("player_clock"); + 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); } @@ -103,76 +101,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerClockTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// 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>, - } +/// 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> 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. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.player_clock().player_id().find(...)`. - pub struct PlayerClockPlayerIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +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) + } +} - impl<'ctx> PlayerClockTableHandle<'ctx> { - /// Get a handle on the `player_id` unique index on the table `player_clock`. - pub fn player_id(&self) -> PlayerClockPlayerIdUnique<'ctx> { - PlayerClockPlayerIdUnique { - imp: self.imp.get_unique_constraint::("player_id"), - phantom: std::marker::PhantomData, - } - } - } +/// 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. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_clock().player_id().find(...)`. +pub struct PlayerClockPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> PlayerClockPlayerIdUnique<'ctx> { - /// Find the subscribed row whose `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 { - self.imp.find(col_val) - } +impl<'ctx> PlayerClockTableHandle<'ctx> { + /// Get a handle on the `player_id` unique index on the table `player_clock`. + pub fn player_id(&self) -> PlayerClockPlayerIdUnique<'ctx> { + PlayerClockPlayerIdUnique { + imp: self.imp.get_unique_constraint::("player_id"), + phantom: std::marker::PhantomData, } - \ No newline at end of file + } +} + +impl<'ctx> PlayerClockPlayerIdUnique<'ctx> { + /// Find the subscribed row whose `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 { + self.imp.find(col_val) + } +} diff --git a/jong-db/src/db/player_clock_type.rs b/jong-db/src/db/player_clock_type.rs index 6c533e6..e8c0407 100644 --- a/jong-db/src/db/player_clock_type.rs +++ b/jong-db/src/db/player_clock_type.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -19,8 +13,6 @@ pub struct PlayerClock { pub total: u16, } - impl __sdk::InModule for PlayerClock { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/player_hand_table.rs b/jong-db/src/db/player_hand_table.rs index 609edd8..a61a5db 100644 --- a/jong-db/src/db/player_hand_table.rs +++ b/jong-db/src/db/player_hand_table.rs @@ -2,15 +2,10 @@ // 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, -}; +use super::db_tile_type::DbTile; use super::player_hand_type::PlayerHand; use super::turn_state_type::TurnState; -use super::db_tile_type::DbTile; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `player_hand`. /// @@ -51,8 +46,12 @@ impl<'ctx> __sdk::Table for PlayerHandTableHandle<'ctx> { type Row = PlayerHand; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = PlayerHandInsertCallbackId; @@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for PlayerHandTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("player_hand"); + let _table = client_cache.get_or_make_table::("player_hand"); _table.add_unique_constraint::("id", |row| &row.id); _table.add_unique_constraint::("player_id", |row| &row.player_id); } @@ -105,76 +103,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerHandTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// Access to the `id` unique index on the table `player_hand`, - /// which allows point queries on the field of the same name - /// via the [`PlayerHandIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.player_hand().id().find(...)`. - pub struct PlayerHandIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// Access to the `id` unique index on the table `player_hand`, +/// which allows point queries on the field of the same name +/// via the [`PlayerHandIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_hand().id().find(...)`. +pub struct PlayerHandIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> PlayerHandTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `player_hand`. - pub fn id(&self) -> PlayerHandIdUnique<'ctx> { - PlayerHandIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } +impl<'ctx> PlayerHandTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `player_hand`. + pub fn id(&self) -> PlayerHandIdUnique<'ctx> { + PlayerHandIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, } + } +} - impl<'ctx> PlayerHandIdUnique<'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_hand`, - /// which allows point queries on the field of the same name - /// via the [`PlayerHandPlayerIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.player_hand().player_id().find(...)`. - pub struct PlayerHandPlayerIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +impl<'ctx> PlayerHandIdUnique<'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) + } +} - impl<'ctx> PlayerHandTableHandle<'ctx> { - /// Get a handle on the `player_id` unique index on the table `player_hand`. - pub fn player_id(&self) -> PlayerHandPlayerIdUnique<'ctx> { - PlayerHandPlayerIdUnique { - imp: self.imp.get_unique_constraint::("player_id"), - phantom: std::marker::PhantomData, - } - } - } +/// Access to the `player_id` unique index on the table `player_hand`, +/// which allows point queries on the field of the same name +/// via the [`PlayerHandPlayerIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_hand().player_id().find(...)`. +pub struct PlayerHandPlayerIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> PlayerHandPlayerIdUnique<'ctx> { - /// Find the subscribed row whose `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 { - self.imp.find(col_val) - } +impl<'ctx> PlayerHandTableHandle<'ctx> { + /// Get a handle on the `player_id` unique index on the table `player_hand`. + pub fn player_id(&self) -> PlayerHandPlayerIdUnique<'ctx> { + PlayerHandPlayerIdUnique { + imp: self.imp.get_unique_constraint::("player_id"), + phantom: std::marker::PhantomData, } - \ No newline at end of file + } +} + +impl<'ctx> PlayerHandPlayerIdUnique<'ctx> { + /// Find the subscribed row whose `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 { + self.imp.find(col_val) + } +} diff --git a/jong-db/src/db/player_hand_type.rs b/jong-db/src/db/player_hand_type.rs index 7e62fa6..b8255d7 100644 --- a/jong-db/src/db/player_hand_type.rs +++ b/jong-db/src/db/player_hand_type.rs @@ -2,15 +2,10 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -use super::turn_state_type::TurnState; 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)] @@ -18,13 +13,11 @@ pub struct PlayerHand { pub id: u32, pub player_id: u32, pub turn_state: TurnState, - pub pond: Vec::, - pub hand: Vec::, - pub working_tile: Option::, + pub pond: Vec, + pub hand: Vec, + pub working_tile: Option, } - impl __sdk::InModule for PlayerHand { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/player_or_bot_type.rs b/jong-db/src/db/player_or_bot_type.rs index eb5d35c..538d940 100644 --- a/jong-db/src/db/player_or_bot_type.rs +++ b/jong-db/src/db/player_or_bot_type.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -16,12 +10,8 @@ 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 index 0aa30cd..b83dd9b 100644 --- a/jong-db/src/db/player_table.rs +++ b/jong-db/src/db/player_table.rs @@ -2,13 +2,8 @@ // 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, -}; use super::player_type::Player; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `player`. /// @@ -49,8 +44,12 @@ 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() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = PlayerInsertCallbackId; @@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("player"); + 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); } @@ -103,76 +101,75 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// 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>, - } +/// 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> 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> 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) + } +} - 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, - } - } - } +/// 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> 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) - } +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, } - \ No newline at end of file + } +} + +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) + } +} diff --git a/jong-db/src/db/player_type.rs b/jong-db/src/db/player_type.rs index 4e0df5a..318aa2a 100644 --- a/jong-db/src/db/player_type.rs +++ b/jong-db/src/db/player_type.rs @@ -2,27 +2,19 @@ // 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, -}; - +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 name: Option, pub lobby_id: u32, pub ready: bool, pub sort: bool, } - impl __sdk::InModule for Player { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/rank_type.rs b/jong-db/src/db/rank_type.rs index 53c89f3..5b40b70 100644 --- a/jong-db/src/db/rank_type.rs +++ b/jong-db/src/db/rank_type.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -16,8 +10,6 @@ pub struct Rank { pub number: u8, } - impl __sdk::InModule for Rank { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/set_ready_reducer.rs b/jong-db/src/db/set_ready_reducer.rs index 901b840..bebd7cf 100644 --- a/jong-db/src/db/set_ready_reducer.rs +++ b/jong-db/src/db/set_ready_reducer.rs @@ -2,13 +2,7 @@ // 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, -}; - +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -18,10 +12,8 @@ pub(super) struct SetReadyArgs { impl From for super::Reducer { fn from(args: SetReadyArgs) -> Self { - Self::SetReady { - ready: args.ready, -} -} + Self::SetReady { ready: args.ready } + } } impl __sdk::InModule for SetReadyArgs { @@ -40,8 +32,7 @@ pub trait set_ready { /// 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 by listening for [`Self::on_set_ready`] callbacks. - fn set_ready(&self, ready: bool, -) -> __sdk::Result<()>; + fn set_ready(&self, ready: bool) -> __sdk::Result<()>; /// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] @@ -49,35 +40,39 @@ pub trait set_ready { /// /// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`] /// to cancel the callback. - fn on_set_ready(&self, callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static) -> SetReadyCallbackId; + fn on_set_ready( + &self, + callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static, + ) -> SetReadyCallbackId; /// Cancel a callback previously registered by [`Self::on_set_ready`], /// causing it not to run in the future. fn remove_on_set_ready(&self, callback: SetReadyCallbackId); } impl set_ready for super::RemoteReducers { - fn set_ready(&self, ready: bool, -) -> __sdk::Result<()> { - self.imp.call_reducer("set_ready", SetReadyArgs { ready, }) + fn set_ready(&self, ready: bool) -> __sdk::Result<()> { + self.imp.call_reducer("set_ready", SetReadyArgs { ready }) } fn on_set_ready( &self, - mut callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static, + mut callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static, ) -> SetReadyCallbackId { SetReadyCallbackId(self.imp.on_reducer( "set_ready", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { - event: __sdk::ReducerEvent { - reducer: super::Reducer::SetReady { - ready, + event: + __sdk::ReducerEvent { + reducer: super::Reducer::SetReady { ready }, + .. }, - .. - }, .. - } = ctx else { unreachable!() }; - callback(ctx, ready, ) + } = ctx + else { + unreachable!() + }; + callback(ctx, ready) }), )) } @@ -105,4 +100,3 @@ impl set_flags_for_set_ready for super::SetReducerFlags { self.imp.set_call_reducer_flags("set_ready", flags); } } - diff --git a/jong-db/src/db/shuffle_deal_reducer.rs b/jong-db/src/db/shuffle_deal_reducer.rs deleted file mode 100644 index 06b1b23..0000000 --- a/jong-db/src/db/shuffle_deal_reducer.rs +++ /dev/null @@ -1,105 +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 ShuffleDealArgs { - pub lobby_id: u32, -} - -impl From for super::Reducer { - fn from(args: ShuffleDealArgs) -> Self { - Self::ShuffleDeal { - lobby_id: args.lobby_id, - } - } -} - -impl __sdk::InModule for ShuffleDealArgs { - type Module = super::RemoteModule; -} - -pub struct ShuffleDealCallbackId(__sdk::CallbackId); - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `shuffle_deal`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait shuffle_deal { - /// Request that the remote module invoke the reducer `shuffle_deal` 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 its status can be observed by listening for [`Self::on_shuffle_deal`] callbacks. - fn shuffle_deal(&self, lobby_id: u32) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `shuffle_deal`. - /// - /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] - /// to determine the reducer's status. - /// - /// The returned [`ShuffleDealCallbackId`] can be passed to [`Self::remove_on_shuffle_deal`] - /// to cancel the callback. - fn on_shuffle_deal( - &self, - callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, - ) -> ShuffleDealCallbackId; - /// Cancel a callback previously registered by [`Self::on_shuffle_deal`], - /// causing it not to run in the future. - fn remove_on_shuffle_deal(&self, callback: ShuffleDealCallbackId); -} - -impl shuffle_deal for super::RemoteReducers { - fn shuffle_deal(&self, lobby_id: u32) -> __sdk::Result<()> { - self.imp - .call_reducer("shuffle_deal", ShuffleDealArgs { lobby_id }) - } - fn on_shuffle_deal( - &self, - mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static, - ) -> ShuffleDealCallbackId { - ShuffleDealCallbackId(self.imp.on_reducer( - "shuffle_deal", - Box::new(move |ctx: &super::ReducerEventContext| { - #[allow(irrefutable_let_patterns)] - let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::ShuffleDeal { lobby_id }, - .. - }, - .. - } = ctx - else { - unreachable!() - }; - callback(ctx, lobby_id) - }), - )) - } - fn remove_on_shuffle_deal(&self, callback: ShuffleDealCallbackId) { - self.imp.remove_on_reducer("shuffle_deal", callback.0) - } -} - -#[allow(non_camel_case_types)] -#[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `shuffle_deal`. -/// -/// Implemented for [`super::SetReducerFlags`]. -/// -/// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_shuffle_deal { - /// Set the call-reducer flags for the reducer `shuffle_deal` to `flags`. - /// - /// This type is currently unstable and may be removed without a major version bump. - fn shuffle_deal(&self, flags: __ws::CallReducerFlags); -} - -impl set_flags_for_shuffle_deal for super::SetReducerFlags { - fn shuffle_deal(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("shuffle_deal", flags); - } -} diff --git a/jong-db/src/db/skip_call_reducer.rs b/jong-db/src/db/skip_call_reducer.rs deleted file mode 100644 index a78c70a..0000000 --- a/jong-db/src/db/skip_call_reducer.rs +++ /dev/null @@ -1,100 +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 SkipCallArgs {} - -impl From for super::Reducer { - fn from(args: SkipCallArgs) -> Self { - Self::SkipCall - } -} - -impl __sdk::InModule for SkipCallArgs { - type Module = super::RemoteModule; -} - -pub struct SkipCallCallbackId(__sdk::CallbackId); - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `skip_call`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait skip_call { - /// Request that the remote module invoke the reducer `skip_call` 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 its status can be observed by listening for [`Self::on_skip_call`] callbacks. - fn skip_call(&self) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `skip_call`. - /// - /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] - /// to determine the reducer's status. - /// - /// The returned [`SkipCallCallbackId`] can be passed to [`Self::remove_on_skip_call`] - /// to cancel the callback. - fn on_skip_call( - &self, - callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> SkipCallCallbackId; - /// Cancel a callback previously registered by [`Self::on_skip_call`], - /// causing it not to run in the future. - fn remove_on_skip_call(&self, callback: SkipCallCallbackId); -} - -impl skip_call for super::RemoteReducers { - fn skip_call(&self) -> __sdk::Result<()> { - self.imp.call_reducer("skip_call", SkipCallArgs {}) - } - fn on_skip_call( - &self, - mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> SkipCallCallbackId { - SkipCallCallbackId(self.imp.on_reducer( - "skip_call", - Box::new(move |ctx: &super::ReducerEventContext| { - #[allow(irrefutable_let_patterns)] - let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::SkipCall {}, - .. - }, - .. - } = ctx - else { - unreachable!() - }; - callback(ctx) - }), - )) - } - fn remove_on_skip_call(&self, callback: SkipCallCallbackId) { - self.imp.remove_on_reducer("skip_call", callback.0) - } -} - -#[allow(non_camel_case_types)] -#[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `skip_call`. -/// -/// Implemented for [`super::SetReducerFlags`]. -/// -/// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_skip_call { - /// Set the call-reducer flags for the reducer `skip_call` to `flags`. - /// - /// This type is currently unstable and may be removed without a major version bump. - fn skip_call(&self, flags: __ws::CallReducerFlags); -} - -impl set_flags_for_skip_call for super::SetReducerFlags { - fn skip_call(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("skip_call", flags); - } -} diff --git a/jong-db/src/db/start_game_reducer.rs b/jong-db/src/db/start_game_reducer.rs deleted file mode 100644 index 5eb59c1..0000000 --- a/jong-db/src/db/start_game_reducer.rs +++ /dev/null @@ -1,100 +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 StartGameArgs {} - -impl From for super::Reducer { - fn from(args: StartGameArgs) -> Self { - Self::StartGame - } -} - -impl __sdk::InModule for StartGameArgs { - type Module = super::RemoteModule; -} - -pub struct StartGameCallbackId(__sdk::CallbackId); - -#[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `start_game`. -/// -/// Implemented for [`super::RemoteReducers`]. -pub trait start_game { - /// Request that the remote module invoke the reducer `start_game` 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 its status can be observed by listening for [`Self::on_start_game`] callbacks. - fn start_game(&self) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `start_game`. - /// - /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] - /// to determine the reducer's status. - /// - /// The returned [`StartGameCallbackId`] can be passed to [`Self::remove_on_start_game`] - /// to cancel the callback. - fn on_start_game( - &self, - callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> StartGameCallbackId; - /// Cancel a callback previously registered by [`Self::on_start_game`], - /// causing it not to run in the future. - fn remove_on_start_game(&self, callback: StartGameCallbackId); -} - -impl start_game for super::RemoteReducers { - fn start_game(&self) -> __sdk::Result<()> { - self.imp.call_reducer("start_game", StartGameArgs {}) - } - fn on_start_game( - &self, - mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static, - ) -> StartGameCallbackId { - StartGameCallbackId(self.imp.on_reducer( - "start_game", - Box::new(move |ctx: &super::ReducerEventContext| { - #[allow(irrefutable_let_patterns)] - let super::ReducerEventContext { - event: - __sdk::ReducerEvent { - reducer: super::Reducer::StartGame {}, - .. - }, - .. - } = ctx - else { - unreachable!() - }; - callback(ctx) - }), - )) - } - fn remove_on_start_game(&self, callback: StartGameCallbackId) { - self.imp.remove_on_reducer("start_game", callback.0) - } -} - -#[allow(non_camel_case_types)] -#[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `start_game`. -/// -/// Implemented for [`super::SetReducerFlags`]. -/// -/// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_start_game { - /// Set the call-reducer flags for the reducer `start_game` to `flags`. - /// - /// This type is currently unstable and may be removed without a major version bump. - fn start_game(&self, flags: __ws::CallReducerFlags); -} - -impl set_flags_for_start_game for super::SetReducerFlags { - fn start_game(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("start_game", flags); - } -} diff --git a/jong-db/src/db/suit_type.rs b/jong-db/src/db/suit_type.rs index 53d5b31..be17c21 100644 --- a/jong-db/src/db/suit_type.rs +++ b/jong-db/src/db/suit_type.rs @@ -2,16 +2,11 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; +use super::dragon_type::Dragon; use super::rank_type::Rank; use super::wind_type::Wind; -use super::dragon_type::Dragon; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -25,12 +20,8 @@ pub enum Suit { Wind(Wind), Dragon(Dragon), - } - - impl __sdk::InModule for Suit { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/tile_table.rs b/jong-db/src/db/tile_table.rs index 9075ccf..8d188eb 100644 --- a/jong-db/src/db/tile_table.rs +++ b/jong-db/src/db/tile_table.rs @@ -2,14 +2,9 @@ // 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, -}; use super::db_tile_type::DbTile; use super::tile_type::Tile; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `tile`. /// @@ -50,8 +45,12 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> { type Row = DbTile; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = TileInsertCallbackId; @@ -82,8 +81,7 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("tile"); + let _table = client_cache.get_or_make_table::("tile"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct TileUpdateCallbackId(__sdk::CallbackId); @@ -103,46 +101,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for TileTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// Access to the `id` unique index on the table `tile`, - /// which allows point queries on the field of the same name - /// via the [`TileIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.tile().id().find(...)`. - pub struct TileIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// Access to the `id` unique index on the table `tile`, +/// which allows point queries on the field of the same name +/// via the [`TileIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.tile().id().find(...)`. +pub struct TileIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> TileTableHandle<'ctx> { - /// Get a handle on the `id` unique index on the table `tile`. - pub fn id(&self) -> TileIdUnique<'ctx> { - TileIdUnique { - imp: self.imp.get_unique_constraint::("id"), - phantom: std::marker::PhantomData, - } - } +impl<'ctx> TileTableHandle<'ctx> { + /// Get a handle on the `id` unique index on the table `tile`. + pub fn id(&self) -> TileIdUnique<'ctx> { + TileIdUnique { + imp: self.imp.get_unique_constraint::("id"), + phantom: std::marker::PhantomData, } + } +} - impl<'ctx> TileIdUnique<'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) - } - } - \ No newline at end of file +impl<'ctx> TileIdUnique<'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) + } +} diff --git a/jong-db/src/db/tile_type.rs b/jong-db/src/db/tile_type.rs index 6c56495..64b1919 100644 --- a/jong-db/src/db/tile_type.rs +++ b/jong-db/src/db/tile_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; use super::suit_type::Suit; @@ -17,8 +12,6 @@ pub struct Tile { pub suit: Suit, } - impl __sdk::InModule for Tile { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/turn_state_type.rs b/jong-db/src/db/turn_state_type.rs index 681e72c..e09ddbe 100644 --- a/jong-db/src/db/turn_state_type.rs +++ b/jong-db/src/db/turn_state_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -24,12 +19,8 @@ pub enum TurnState { RonChiiPonKan, End, - } - - impl __sdk::InModule for TurnState { type Module = super::RemoteModule; } - diff --git a/jong-db/src/db/wall_table.rs b/jong-db/src/db/wall_table.rs index e9f4d46..1f920d6 100644 --- a/jong-db/src/db/wall_table.rs +++ b/jong-db/src/db/wall_table.rs @@ -2,14 +2,9 @@ // 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, -}; -use super::db_wall_type::DbWall; use super::db_tile_type::DbTile; +use super::db_wall_type::DbWall; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `wall`. /// @@ -50,8 +45,12 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> { type Row = DbWall; type EventContext = super::EventContext; - fn count(&self) -> u64 { self.imp.count() } - fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } type InsertCallbackId = WallInsertCallbackId; @@ -82,8 +81,7 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> { #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { - - let _table = client_cache.get_or_make_table::("wall"); + let _table = client_cache.get_or_make_table::("wall"); _table.add_unique_constraint::("lobby_id", |row| &row.lobby_id); } pub struct WallUpdateCallbackId(__sdk::CallbackId); @@ -103,46 +101,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for WallTableHandle<'ctx> { } } - #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { - __sdk::InternalError::failed_parse( - "TableUpdate", - "TableUpdate", - ).with_cause(e).into() + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() }) } - /// Access to the `lobby_id` unique index on the table `wall`, - /// which allows point queries on the field of the same name - /// via the [`WallLobbyIdUnique::find`] method. - /// - /// Users are encouraged not to explicitly reference this type, - /// but to directly chain method calls, - /// like `ctx.db.wall().lobby_id().find(...)`. - pub struct WallLobbyIdUnique<'ctx> { - imp: __sdk::UniqueConstraintHandle, - phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, - } +/// Access to the `lobby_id` unique index on the table `wall`, +/// which allows point queries on the field of the same name +/// via the [`WallLobbyIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.wall().lobby_id().find(...)`. +pub struct WallLobbyIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} - impl<'ctx> WallTableHandle<'ctx> { - /// Get a handle on the `lobby_id` unique index on the table `wall`. - pub fn lobby_id(&self) -> WallLobbyIdUnique<'ctx> { - WallLobbyIdUnique { - imp: self.imp.get_unique_constraint::("lobby_id"), - phantom: std::marker::PhantomData, - } - } +impl<'ctx> WallTableHandle<'ctx> { + /// Get a handle on the `lobby_id` unique index on the table `wall`. + pub fn lobby_id(&self) -> WallLobbyIdUnique<'ctx> { + WallLobbyIdUnique { + imp: self.imp.get_unique_constraint::("lobby_id"), + phantom: std::marker::PhantomData, } + } +} - impl<'ctx> WallLobbyIdUnique<'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 { - self.imp.find(col_val) - } - } - \ No newline at end of file +impl<'ctx> WallLobbyIdUnique<'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 { + self.imp.find(col_val) + } +} diff --git a/jong-db/src/db/wind_type.rs b/jong-db/src/db/wind_type.rs index 8f9800c..a1c3965 100644 --- a/jong-db/src/db/wind_type.rs +++ b/jong-db/src/db/wind_type.rs @@ -2,12 +2,7 @@ // 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, -}; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; #[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] #[sats(crate = __lib)] @@ -20,12 +15,8 @@ pub enum Wind { Shaa, Pei, - } - - impl __sdk::InModule for Wind { type Module = super::RemoteModule; } - From 222459f828f05f2b693b3b1ace201310f532b95d Mon Sep 17 00:00:00 2001 From: Tao Tien <29749622+taotien@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:39:51 -0800 Subject: [PATCH 5/5] (stash) --- .helix/ignore | 1 + Cargo.lock | 247 ++++++++++++++++++---- Cargo.toml | 4 +- devenv.lock | 4 +- devenv.nix | 2 +- jong-db/src/db/bot_table.rs | 16 ++ jong-db/src/db/bot_type.rs | 44 ++++ jong-db/src/db/db_tile_type.rs | 34 +++ jong-db/src/db/db_wall_type.rs | 34 +++ jong-db/src/db/game_timer_table.rs | 16 ++ jong-db/src/db/game_timer_type.rs | 38 ++++ jong-db/src/db/lobby_table.rs | 16 ++ jong-db/src/db/lobby_type.rs | 40 ++++ jong-db/src/db/logged_out_player_table.rs | 16 ++ jong-db/src/db/mod.rs | 13 +- jong-db/src/db/player_clock_table.rs | 16 ++ jong-db/src/db/player_clock_type.rs | 40 ++++ jong-db/src/db/player_hand_table.rs | 16 ++ jong-db/src/db/player_hand_type.rs | 44 ++++ jong-db/src/db/player_table.rs | 16 ++ jong-db/src/db/player_type.rs | 46 ++++ jong-db/src/db/tile_table.rs | 16 ++ jong-db/src/db/view_hand_table.rs | 113 ++++++++++ jong-db/src/db/wall_table.rs | 16 ++ jong-db/src/lib.rs | 2 + jong-line/src/reducers.rs | 3 +- jong-line/src/reducers/lobby.rs | 2 + jong-line/src/tables.rs | 16 +- jong/src/riichi.rs | 124 ++++------- jong/src/tui.rs | 3 +- justfile | 7 +- 31 files changed, 870 insertions(+), 135 deletions(-) create mode 100644 jong-db/src/db/view_hand_table.rs diff --git a/.helix/ignore b/.helix/ignore index 25da40d..10f3355 100644 --- a/.helix/ignore +++ b/.helix/ignore @@ -1 +1,2 @@ jong-db +bevy_spacetimedb diff --git a/Cargo.lock b/Cargo.lock index 87787c4..f3d8fff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -500,7 +500,7 @@ dependencies = [ "derive_more 2.1.1", "downcast-rs 2.0.2", "either", - "petgraph", + "petgraph 0.8.3", "ron", "serde", "smallvec", @@ -1303,7 +1303,7 @@ dependencies = [ "glam", "indexmap 2.13.0", "inventory", - "petgraph", + "petgraph 0.8.3", "serde", "smallvec", "smol_str", @@ -2153,6 +2153,18 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -2733,6 +2745,12 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" +[[package]] +name = "ecow" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78e4f79b296fbaab6ce2e22d52cb4c7f010fe0ebe7a32e34fa25885fd797bd02" + [[package]] name = "either" version = "1.15.0" @@ -2770,6 +2788,12 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + [[package]] name = "enum-as-inner" version = "0.6.1" @@ -2782,6 +2806,26 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "enum-map" +version = "2.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9" +dependencies = [ + "enum-map-derive", +] + +[[package]] +name = "enum-map-derive" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "env_filter" version = "0.1.4" @@ -3751,6 +3795,22 @@ dependencies = [ "libc", ] +[[package]] +name = "insta" +version = "1.46.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4" +dependencies = [ + "console", + "once_cell", + "regex", + "serde", + "similar", + "tempfile", + "toml_edit", + "toml_writer", +] + [[package]] name = "instability" version = "0.3.11" @@ -4819,15 +4879,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "ordered-float" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2c1f9f56e534ac6a9b8a4600bdf0f530fb393b5f393e7b4d03489c3cf0c3f01" -dependencies = [ - "num-traits", -] - [[package]] name = "owned_ttf_parser" version = "0.25.1" @@ -4927,6 +4978,16 @@ dependencies = [ "sha2", ] +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset 0.4.2", + "indexmap 2.13.0", +] + [[package]] name = "petgraph" version = "0.8.3" @@ -5772,6 +5833,15 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_spanned" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_with" version = "3.16.1" @@ -5887,6 +5957,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + [[package]] name = "siphasher" version = "1.0.2" @@ -5980,9 +6056,9 @@ dependencies = [ [[package]] name = "spacetimedb" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83af98280374b59796296f512f7855fd19e19240a358bb7706a54f1c4e4e7dff" +checksum = "503ac8c991a76998d4ba699ef9b7f0085d3d7c363d1fcce4219314f909746bca" dependencies = [ "anyhow", "bytemuck", @@ -5998,13 +6074,14 @@ dependencies = [ "spacetimedb-bindings-sys", "spacetimedb-lib", "spacetimedb-primitives", + "spacetimedb-query-builder", ] [[package]] name = "spacetimedb-bindings-macro" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d8dbedaa26e2e59d886a19bd2b784356d8d008274046f735c9185f9943bd912" +checksum = "1214628a7c29ee58255d511b7c4dbaaa463bc5022dba9401f264c1c85b5a891c" dependencies = [ "heck 0.4.1", "humantime", @@ -6016,18 +6093,18 @@ dependencies = [ [[package]] name = "spacetimedb-bindings-sys" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0d30e1655731b1564b7094a6213ef6c354ea920e3c04424e55ad377a1bc3e2" +checksum = "d4777d90692bade6601887a21a074b71c157b34a92a5cfc8d5ecb46a0c571094" dependencies = [ "spacetimedb-primitives", ] [[package]] name = "spacetimedb-client-api-messages" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93dac13fc3dbd43698823c287c3839a3c13391dd9b33414a724c85335d1aa966" +checksum = "745d7ab0f81e3f6333d3ee353ce314b73841fbfe06adad69ab43efa791301da3" dependencies = [ "bytes", "bytestring", @@ -6047,12 +6124,13 @@ dependencies = [ [[package]] name = "spacetimedb-data-structures" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5d42998701abb5fd4878e0ceac31bf208caccc453491620f0ff59e2e75de9" +checksum = "b5d85162537b1eeb6eac39383e34ca27aafcbf26987753172ca3de1de1e3a838" dependencies = [ "ahash", "crossbeam-queue", + "either", "hashbrown 0.16.1", "nohash-hasher", "smallvec", @@ -6061,9 +6139,9 @@ dependencies = [ [[package]] name = "spacetimedb-lib" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f7284d48bcfddc7c091756c6d5d3cc9a847b95778c636fdd03b9538d74a57c7" +checksum = "6c5e91c66b10dc38cce01928d3f77313276e34c635504e54afdec6f186a2fc9c" dependencies = [ "anyhow", "bitflags 2.11.0", @@ -6071,6 +6149,7 @@ dependencies = [ "chrono", "derive_more 0.99.20", "enum-as-inner", + "enum-map", "hex", "itertools 0.12.1", "log", @@ -6083,10 +6162,20 @@ dependencies = [ ] [[package]] -name = "spacetimedb-metrics" -version = "1.11.3" +name = "spacetimedb-memory-usage" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a759e05414bd0f41a1bd498173c3cc2aa94d83b37e564dd0f597aa5c026f3ad" +checksum = "eb9c081d3ffafa9c2fa11194b4ea3329773d979e342944b0128282bcbf5d3343" +dependencies = [ + "decorum", + "ethnum", +] + +[[package]] +name = "spacetimedb-metrics" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985858969f693529c8624ce195cb747a34f7c84f3097418f595f795c0559fbd1" dependencies = [ "arrayvec", "itertools 0.12.1", @@ -6096,22 +6185,32 @@ dependencies = [ [[package]] name = "spacetimedb-primitives" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2dc124963dd166ecde2b4d8f0e5ed4cfd27a20d7f6bb9e84d7eff46cc520b5" +checksum = "8f0321a161fa39f0937aceb436b47115cd811212799ddaf7996a8ecac3476d8d" dependencies = [ "bitflags 2.11.0", "either", "enum-as-inner", "itertools 0.12.1", "nohash-hasher", + "spacetimedb-memory-usage", +] + +[[package]] +name = "spacetimedb-query-builder" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df8137b6dc2739d4efbc6218c5fb106f1e105a1345819a74053b677bd38c429" +dependencies = [ + "spacetimedb-lib", ] [[package]] name = "spacetimedb-sats" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df06586ffc862efd795425854cc2469c561aca5b95f5df2212aa29ef14a56f8a" +checksum = "f4e07b1bc933156b0cbe6b6c759e57381ce95df52c4522d9c3d71df59c01cf20" dependencies = [ "anyhow", "arrayvec", @@ -6132,6 +6231,7 @@ dependencies = [ "sha3", "smallvec", "spacetimedb-bindings-macro", + "spacetimedb-memory-usage", "spacetimedb-metrics", "spacetimedb-primitives", "thiserror 1.0.69", @@ -6139,10 +6239,40 @@ dependencies = [ ] [[package]] -name = "spacetimedb-sdk" -version = "1.11.3" +name = "spacetimedb-schema" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b12876a6ebba7685ad52bcd1b540cd4d220bd4cf37746b3a776cb140ebc52483" +checksum = "c2763b4769028f111032f00b35635f6cbb0562f54a59d05775f5ea66d7b8f8d2" +dependencies = [ + "anyhow", + "derive_more 0.99.20", + "ecow", + "enum-as-inner", + "enum-map", + "indexmap 2.13.0", + "insta", + "itertools 0.12.1", + "lazy_static", + "petgraph 0.6.5", + "serde_json", + "smallvec", + "spacetimedb-data-structures", + "spacetimedb-lib", + "spacetimedb-memory-usage", + "spacetimedb-primitives", + "spacetimedb-sats", + "spacetimedb-sql-parser", + "termcolor", + "thiserror 1.0.69", + "unicode-ident", + "unicode-normalization", +] + +[[package]] +name = "spacetimedb-sdk" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243f7b433aa0ba1d665aeb9db397b9bd40698d80817840d8fa8d8bfe74e99f00" dependencies = [ "anymap", "base64 0.21.7", @@ -6161,12 +6291,26 @@ dependencies = [ "spacetimedb-data-structures", "spacetimedb-lib", "spacetimedb-metrics", + "spacetimedb-query-builder", "spacetimedb-sats", + "spacetimedb-schema", "thiserror 1.0.69", "tokio", "tokio-tungstenite", ] +[[package]] +name = "spacetimedb-sql-parser" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cd63f69d4d6b074771830d8f8d12ce52c253179940c1bd02a50adeba7a9485" +dependencies = [ + "derive_more 0.99.20", + "spacetimedb-lib", + "sqlparser", + "thiserror 1.0.69", +] + [[package]] name = "spin" version = "0.10.0" @@ -6185,6 +6329,15 @@ dependencies = [ "bitflags 2.11.0", ] +[[package]] +name = "sqlparser" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0272b7bb0a225320170c99901b4b5fb3a4384e255a7f2cc228f61e2ba3893e75" +dependencies = [ + "log", +] + [[package]] name = "stable_deref_trait" version = "1.2.1" @@ -6410,7 +6563,7 @@ dependencies = [ "nix 0.29.0", "num-derive", "num-traits", - "ordered-float 4.6.0", + "ordered-float", "pest", "pest_derive", "phf", @@ -6631,8 +6784,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" dependencies = [ "indexmap 2.13.0", + "serde_core", + "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -6645,6 +6801,12 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_writer" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" + [[package]] name = "tracing" version = "0.1.44" @@ -6832,6 +6994,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-script" version = "0.5.8" @@ -7251,7 +7422,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac" dependencies = [ "log", - "ordered-float 4.6.0", + "ordered-float", "strsim", "thiserror 1.0.69", "wezterm-dynamic-derive", @@ -7399,7 +7570,7 @@ dependencies = [ "ndk-sys 0.6.0+11769913", "objc", "once_cell", - "ordered-float 5.0.0", + "ordered-float", "parking_lot", "portable-atomic", "portable-atomic-util", @@ -8317,7 +8488,3 @@ name = "zmij" version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" - -[[patch.unused]] -name = "bevy_ratatui" -version = "0.10.0" diff --git a/Cargo.toml b/Cargo.toml index cecf3ee..1c9bb29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ bevy.default-features = false bevy_ratatui = "0.11.1" bevy_spacetimedb = "0.7" -spacetimedb.version = "1.11.*" +spacetimedb.version = "1.12.*" spacetimedb.features = ["unstable"] -spacetimedb-sdk = "1.11.*" +spacetimedb-sdk = "1.12.*" strum.version = "0.27.2" strum.features = ["derive"] diff --git a/devenv.lock b/devenv.lock index 3dda13a..08cedca 100644 --- a/devenv.lock +++ b/devenv.lock @@ -125,10 +125,10 @@ ] }, "locked": { - "lastModified": 1771642886, + "lastModified": 1771729765, "owner": "oxalica", "repo": "rust-overlay", - "rev": "85078369717bdbe1f266c9eaad5e66956fb6feea", + "rev": "be926cb1a76e8450ab2b92121b2e88d09fa4d41c", "type": "github" }, "original": { diff --git a/devenv.nix b/devenv.nix index 925cfa6..9899754 100644 --- a/devenv.nix +++ b/devenv.nix @@ -24,7 +24,7 @@ # spacetimedb openssl binaryen - spacetimedb + # spacetimedb # bevy Linux # Audio (Linux only) diff --git a/jong-db/src/db/bot_table.rs b/jong-db/src/db/bot_table.rs index e9379ed..d062239 100644 --- a/jong-db/src/db/bot_table.rs +++ b/jong-db/src/db/bot_table.rs @@ -142,3 +142,19 @@ impl<'ctx> BotIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `Bot`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait botQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `Bot`. + fn bot(&self) -> __sdk::__query_builder::Table; +} + +impl botQueryTableAccess for __sdk::QueryTableAccessor { + fn bot(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("bot") + } +} diff --git a/jong-db/src/db/bot_type.rs b/jong-db/src/db/bot_type.rs index dcad657..58acb75 100644 --- a/jong-db/src/db/bot_type.rs +++ b/jong-db/src/db/bot_type.rs @@ -21,3 +21,47 @@ pub struct Bot { impl __sdk::InModule for Bot { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `Bot`. +/// +/// Provides typed access to columns for query building. +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>, +} + +impl __sdk::__query_builder::HasCols for Bot { + type Cols = BotCols; + fn cols(table_name: &'static str) -> Self::Cols { + 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"), + } + } +} + +/// Indexed column accessor struct for the table `Bot`. +/// +/// Provides typed access to indexed columns for query building. +pub struct BotIxCols { + pub id: __sdk::__query_builder::IxCol, + pub lobby_id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for Bot { + type IxCols = BotIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + BotIxCols { + id: __sdk::__query_builder::IxCol::new(table_name, "id"), + lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), + } + } +} diff --git a/jong-db/src/db/db_tile_type.rs b/jong-db/src/db/db_tile_type.rs index cf5c736..9bd4f8e 100644 --- a/jong-db/src/db/db_tile_type.rs +++ b/jong-db/src/db/db_tile_type.rs @@ -16,3 +16,37 @@ pub struct DbTile { impl __sdk::InModule for DbTile { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `DbTile`. +/// +/// Provides typed access to columns for query building. +pub struct DbTileCols { + pub id: __sdk::__query_builder::Col, + pub tile: __sdk::__query_builder::Col, +} + +impl __sdk::__query_builder::HasCols for DbTile { + type Cols = DbTileCols; + fn cols(table_name: &'static str) -> Self::Cols { + DbTileCols { + id: __sdk::__query_builder::Col::new(table_name, "id"), + tile: __sdk::__query_builder::Col::new(table_name, "tile"), + } + } +} + +/// Indexed column accessor struct for the table `DbTile`. +/// +/// Provides typed access to indexed columns for query building. +pub struct DbTileIxCols { + pub id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for DbTile { + type IxCols = DbTileIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + DbTileIxCols { + id: __sdk::__query_builder::IxCol::new(table_name, "id"), + } + } +} diff --git a/jong-db/src/db/db_wall_type.rs b/jong-db/src/db/db_wall_type.rs index 20688c7..47ec2cc 100644 --- a/jong-db/src/db/db_wall_type.rs +++ b/jong-db/src/db/db_wall_type.rs @@ -16,3 +16,37 @@ pub struct DbWall { impl __sdk::InModule for DbWall { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `DbWall`. +/// +/// Provides typed access to columns for query building. +pub struct DbWallCols { + pub lobby_id: __sdk::__query_builder::Col, + pub tiles: __sdk::__query_builder::Col>, +} + +impl __sdk::__query_builder::HasCols for DbWall { + type Cols = DbWallCols; + fn cols(table_name: &'static str) -> Self::Cols { + DbWallCols { + 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`. +/// +/// Provides typed access to indexed columns for query building. +pub struct DbWallIxCols { + pub lobby_id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for DbWall { + type IxCols = DbWallIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + DbWallIxCols { + lobby_id: __sdk::__query_builder::IxCol::new(table_name, "lobby_id"), + } + } +} diff --git a/jong-db/src/db/game_timer_table.rs b/jong-db/src/db/game_timer_table.rs index 58bdfe0..9d29ade 100644 --- a/jong-db/src/db/game_timer_table.rs +++ b/jong-db/src/db/game_timer_table.rs @@ -171,3 +171,19 @@ impl<'ctx> GameTimerLobbyIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `GameTimer`. +/// +/// 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; +} + +impl game_timerQueryTableAccess for __sdk::QueryTableAccessor { + 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 index cefd735..80b8a73 100644 --- a/jong-db/src/db/game_timer_type.rs +++ b/jong-db/src/db/game_timer_type.rs @@ -15,3 +15,41 @@ pub struct GameTimer { 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"), + } + } +} diff --git a/jong-db/src/db/lobby_table.rs b/jong-db/src/db/lobby_table.rs index 962b676..8d7f499 100644 --- a/jong-db/src/db/lobby_table.rs +++ b/jong-db/src/db/lobby_table.rs @@ -142,3 +142,19 @@ impl<'ctx> LobbyIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `Lobby`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait lobbyQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `Lobby`. + fn lobby(&self) -> __sdk::__query_builder::Table; +} + +impl lobbyQueryTableAccess for __sdk::QueryTableAccessor { + fn lobby(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("lobby") + } +} diff --git a/jong-db/src/db/lobby_type.rs b/jong-db/src/db/lobby_type.rs index 6fca7de..af8dda7 100644 --- a/jong-db/src/db/lobby_type.rs +++ b/jong-db/src/db/lobby_type.rs @@ -20,3 +20,43 @@ pub struct Lobby { impl __sdk::InModule for Lobby { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `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 dealer_idx: __sdk::__query_builder::Col, + pub current_idx: __sdk::__query_builder::Col, + pub game_state: __sdk::__query_builder::Col, +} + +impl __sdk::__query_builder::HasCols for Lobby { + type Cols = LobbyCols; + fn cols(table_name: &'static str) -> Self::Cols { + LobbyCols { + id: __sdk::__query_builder::Col::new(table_name, "id"), + players: __sdk::__query_builder::Col::new(table_name, "players"), + dealer_idx: __sdk::__query_builder::Col::new(table_name, "dealer_idx"), + current_idx: __sdk::__query_builder::Col::new(table_name, "current_idx"), + game_state: __sdk::__query_builder::Col::new(table_name, "game_state"), + } + } +} + +/// Indexed column accessor struct for the table `Lobby`. +/// +/// Provides typed access to indexed columns for query building. +pub struct LobbyIxCols { + pub id: __sdk::__query_builder::IxCol, +} + +impl __sdk::__query_builder::HasIxCols for Lobby { + type IxCols = LobbyIxCols; + fn ix_cols(table_name: &'static str) -> Self::IxCols { + LobbyIxCols { + id: __sdk::__query_builder::IxCol::new(table_name, "id"), + } + } +} diff --git a/jong-db/src/db/logged_out_player_table.rs b/jong-db/src/db/logged_out_player_table.rs index aeaa8a2..1de7240 100644 --- a/jong-db/src/db/logged_out_player_table.rs +++ b/jong-db/src/db/logged_out_player_table.rs @@ -173,3 +173,19 @@ impl<'ctx> LoggedOutPlayerIdentityUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `Player`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait logged_out_playerQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `Player`. + fn logged_out_player(&self) -> __sdk::__query_builder::Table; +} + +impl logged_out_playerQueryTableAccess for __sdk::QueryTableAccessor { + fn logged_out_player(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("logged_out_player") + } +} diff --git a/jong-db/src/db/mod.rs b/jong-db/src/db/mod.rs index de00af9..b1eefc3 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 1.11.3 (commit 02449737ca3b29e7e39679fccbef541a50f32094). +// This was generated using spacetimedb cli version 1.12.0 (commit 4fdb8d923f39ed592931ad4c7e6391ed99b9fe3a). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; @@ -37,6 +37,7 @@ pub mod suit_type; pub mod tile_table; pub mod tile_type; pub mod turn_state_type; +pub mod view_hand_table; pub mod wall_table; pub mod wind_type; @@ -73,6 +74,7 @@ pub use suit_type::Suit; pub use tile_table::*; pub use tile_type::Tile; pub use turn_state_type::TurnState; +pub use view_hand_table::*; pub use wall_table::*; pub use wind_type::Wind; @@ -188,6 +190,7 @@ pub struct DbUpdate { player_clock: __sdk::TableUpdate, player_hand: __sdk::TableUpdate, tile: __sdk::TableUpdate, + view_hand: __sdk::TableUpdate, wall: __sdk::TableUpdate, } @@ -221,6 +224,9 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { "tile" => db_update .tile .append(tile_table::parse_table_update(table_update)?), + "view_hand" => db_update + .view_hand + .append(view_hand_table::parse_table_update(table_update)?), "wall" => db_update .wall .append(wall_table::parse_table_update(table_update)?), @@ -277,6 +283,7 @@ impl __sdk::DbUpdate for DbUpdate { diff.wall = cache .apply_diff_to_table::("wall", &self.wall) .with_updates_by_pk(|row| &row.lobby_id); + diff.view_hand = cache.apply_diff_to_table::("view_hand", &self.view_hand); diff } @@ -294,6 +301,7 @@ pub struct AppliedDiff<'r> { player_clock: __sdk::TableAppliedDiff<'r, PlayerClock>, player_hand: __sdk::TableAppliedDiff<'r, PlayerHand>, tile: __sdk::TableAppliedDiff<'r, DbTile>, + view_hand: __sdk::TableAppliedDiff<'r, PlayerHand>, wall: __sdk::TableAppliedDiff<'r, DbWall>, __unused: std::marker::PhantomData<&'r ()>, } @@ -324,6 +332,7 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> { ); callbacks.invoke_table_row_callbacks::("player_hand", &self.player_hand, event); callbacks.invoke_table_row_callbacks::("tile", &self.tile, event); + callbacks.invoke_table_row_callbacks::("view_hand", &self.view_hand, event); callbacks.invoke_table_row_callbacks::("wall", &self.wall, event); } } @@ -1042,6 +1051,7 @@ impl __sdk::SpacetimeModule for RemoteModule { type DbUpdate = DbUpdate; type AppliedDiff<'r> = AppliedDiff<'r>; type SubscriptionHandle = SubscriptionHandle; + type QueryBuilder = __sdk::QueryBuilder; fn register_tables(client_cache: &mut __sdk::ClientCache) { bot_table::register_table(client_cache); @@ -1052,6 +1062,7 @@ impl __sdk::SpacetimeModule for RemoteModule { player_clock_table::register_table(client_cache); player_hand_table::register_table(client_cache); tile_table::register_table(client_cache); + view_hand_table::register_table(client_cache); wall_table::register_table(client_cache); } } diff --git a/jong-db/src/db/player_clock_table.rs b/jong-db/src/db/player_clock_table.rs index 551f521..79a0eb0 100644 --- a/jong-db/src/db/player_clock_table.rs +++ b/jong-db/src/db/player_clock_table.rs @@ -171,3 +171,19 @@ impl<'ctx> PlayerClockPlayerIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `PlayerClock`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait player_clockQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `PlayerClock`. + fn player_clock(&self) -> __sdk::__query_builder::Table; +} + +impl player_clockQueryTableAccess for __sdk::QueryTableAccessor { + fn player_clock(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("player_clock") + } +} diff --git a/jong-db/src/db/player_clock_type.rs b/jong-db/src/db/player_clock_type.rs index e8c0407..6ae3212 100644 --- a/jong-db/src/db/player_clock_type.rs +++ b/jong-db/src/db/player_clock_type.rs @@ -16,3 +16,43 @@ pub struct PlayerClock { impl __sdk::InModule for PlayerClock { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `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, +} + +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"), + } + } +} + +/// Indexed column accessor struct for the table `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, +} + +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_hand_table.rs b/jong-db/src/db/player_hand_table.rs index a61a5db..4b1af06 100644 --- a/jong-db/src/db/player_hand_table.rs +++ b/jong-db/src/db/player_hand_table.rs @@ -173,3 +173,19 @@ impl<'ctx> PlayerHandPlayerIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `PlayerHand`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait player_handQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `PlayerHand`. + fn player_hand(&self) -> __sdk::__query_builder::Table; +} + +impl player_handQueryTableAccess for __sdk::QueryTableAccessor { + fn player_hand(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("player_hand") + } +} diff --git a/jong-db/src/db/player_hand_type.rs b/jong-db/src/db/player_hand_type.rs index b8255d7..dfa7dbf 100644 --- a/jong-db/src/db/player_hand_type.rs +++ b/jong-db/src/db/player_hand_type.rs @@ -21,3 +21,47 @@ pub struct PlayerHand { impl __sdk::InModule for PlayerHand { type Module = super::RemoteModule; } + +/// Column accessor struct for the table `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 working_tile: __sdk::__query_builder::Col>, +} + +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"), + working_tile: __sdk::__query_builder::Col::new(table_name, "working_tile"), + } + } +} + +/// Indexed column accessor struct for the table `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, +} + +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_table.rs b/jong-db/src/db/player_table.rs index b83dd9b..78db0f7 100644 --- a/jong-db/src/db/player_table.rs +++ b/jong-db/src/db/player_table.rs @@ -173,3 +173,19 @@ impl<'ctx> PlayerIdentityUnique<'ctx> { self.imp.find(col_val) } } + +#[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 index 318aa2a..be770b6 100644 --- a/jong-db/src/db/player_type.rs +++ b/jong-db/src/db/player_type.rs @@ -18,3 +18,49 @@ pub struct Player { 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"), + } + } +} diff --git a/jong-db/src/db/tile_table.rs b/jong-db/src/db/tile_table.rs index 8d188eb..e23f10e 100644 --- a/jong-db/src/db/tile_table.rs +++ b/jong-db/src/db/tile_table.rs @@ -141,3 +141,19 @@ impl<'ctx> TileIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `DbTile`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait tileQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `DbTile`. + fn tile(&self) -> __sdk::__query_builder::Table; +} + +impl tileQueryTableAccess for __sdk::QueryTableAccessor { + fn tile(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("tile") + } +} diff --git a/jong-db/src/db/view_hand_table.rs b/jong-db/src/db/view_hand_table.rs new file mode 100644 index 0000000..1a9adbf --- /dev/null +++ b/jong-db/src/db/view_hand_table.rs @@ -0,0 +1,113 @@ +// 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::db_tile_type::DbTile; +use super::player_hand_type::PlayerHand; +use super::turn_state_type::TurnState; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `view_hand`. +/// +/// Obtain a handle from the [`ViewHandTableAccess::view_hand`] method on [`super::RemoteTables`], +/// like `ctx.db.view_hand()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.view_hand().on_insert(...)`. +pub struct ViewHandTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `view_hand`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait ViewHandTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`ViewHandTableHandle`], which mediates access to the table `view_hand`. + fn view_hand(&self) -> ViewHandTableHandle<'_>; +} + +impl ViewHandTableAccess for super::RemoteTables { + fn view_hand(&self) -> ViewHandTableHandle<'_> { + ViewHandTableHandle { + imp: self.imp.get_table::("view_hand"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct ViewHandInsertCallbackId(__sdk::CallbackId); +pub struct ViewHandDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for ViewHandTableHandle<'ctx> { + type Row = PlayerHand; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = ViewHandInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ViewHandInsertCallbackId { + ViewHandInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: ViewHandInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = ViewHandDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ViewHandDeleteCallbackId { + ViewHandDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: ViewHandDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("view_hand"); +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::TableUpdate<__ws::BsatnFormat>, +) -> __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 `PlayerHand`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait view_handQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `PlayerHand`. + fn view_hand(&self) -> __sdk::__query_builder::Table; +} + +impl view_handQueryTableAccess for __sdk::QueryTableAccessor { + fn view_hand(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("view_hand") + } +} diff --git a/jong-db/src/db/wall_table.rs b/jong-db/src/db/wall_table.rs index 1f920d6..70c4010 100644 --- a/jong-db/src/db/wall_table.rs +++ b/jong-db/src/db/wall_table.rs @@ -141,3 +141,19 @@ impl<'ctx> WallLobbyIdUnique<'ctx> { self.imp.find(col_val) } } + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `DbWall`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait wallQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `DbWall`. + fn wall(&self) -> __sdk::__query_builder::Table; +} + +impl wallQueryTableAccess for __sdk::QueryTableAccessor { + fn wall(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("wall") + } +} diff --git a/jong-db/src/lib.rs b/jong-db/src/lib.rs index 0d2a8d5..0d3befb 100644 --- a/jong-db/src/lib.rs +++ b/jong-db/src/lib.rs @@ -1,4 +1,6 @@ pub mod db; + +pub use conversions::*; pub use db::*; mod conversions { diff --git a/jong-line/src/reducers.rs b/jong-line/src/reducers.rs index a9ce012..151c7a4 100644 --- a/jong-line/src/reducers.rs +++ b/jong-line/src/reducers.rs @@ -87,7 +87,8 @@ pub fn advance_game(ctx: &ReducerContext, mut game_timer: GameTimer) -> Result<( _ => Err(format!("lobby {} in impossible state", lobby.id))?, } - ctx.db.game_timer().id().update(game_timer); + // ctx.db.game_timer().id().update(game_timer); + ctx.db.lobby().id().update(lobby); } else { ctx.db.game_timer().id().delete(game_timer.id); Err(format!( diff --git a/jong-line/src/reducers/lobby.rs b/jong-line/src/reducers/lobby.rs index b51aeac..ebe69c9 100644 --- a/jong-line/src/reducers/lobby.rs +++ b/jong-line/src/reducers/lobby.rs @@ -15,6 +15,8 @@ pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<( .ok_or(format!("cannot find player {}", ctx.sender))?; if lobby_id == 0 { + // TODO check first if player is already in a lobby + let lobby = ctx.db.lobby().insert(Lobby { id: 0, players: vec![PlayerOrBot::Player { id: player.id }], diff --git a/jong-line/src/tables.rs b/jong-line/src/tables.rs index a8ef7d5..4dfc472 100644 --- a/jong-line/src/tables.rs +++ b/jong-line/src/tables.rs @@ -1,6 +1,4 @@ -use std::time::Instant; - -use spacetimedb::{SpacetimeType, table}; +use spacetimedb::{SpacetimeType, ViewContext, table, view}; use jong_types::{ states::{GameState, TurnState}, @@ -47,7 +45,6 @@ pub enum PlayerOrBot { Bot { id: u32 }, } -// FIXME this shant be public, use views #[table(name = player, public)] #[table(name = logged_out_player)] #[derive(Debug)] @@ -98,7 +95,7 @@ pub struct PlayerHand { pub working_tile: Option, } -#[table(name = bot)] +#[table(name = bot, public)] pub struct Bot { #[primary_key] #[auto_inc] @@ -126,3 +123,12 @@ pub struct GameTimer { pub scheduled_at: spacetimedb::ScheduleAt, } + +#[view(name = view_hand, public)] +fn view_hand(ctx: &ViewContext) -> Option { + ctx.db + .player() + .identity() + .find(ctx.sender) + .and_then(|p| ctx.db.player_hand().player_id().find(p.id)) +} diff --git a/jong/src/riichi.rs b/jong/src/riichi.rs index c8aa7d7..73134f5 100644 --- a/jong/src/riichi.rs +++ b/jong/src/riichi.rs @@ -3,7 +3,10 @@ use bevy_spacetimedb::{ ReadInsertUpdateMessage, ReadStdbConnectedMessage, ReadStdbDisconnectedMessage, StdbPlugin, }; -use jong_db::{self, DbConnection, LobbyTableAccess, PlayerTableAccess, RemoteTables}; +use jong_db::{ + self, DbConnection, LobbyTableAccess, PlayerHand, PlayerTableAccess, RemoteTables, + ViewHandTableAccess as _, +}; use jong_db::{add_bot, set_ready}; use jong_types::*; @@ -19,11 +22,10 @@ impl Plugin for Riichi { .with_uri("http://localhost:3000") .with_module_name("jong-line") .with_run_fn(DbConnection::run_threaded) - // TODO why don't I need to call add_reducer? - - // TODO do these need to be subscription & vice-versa? .add_table(RemoteTables::player) .add_table(RemoteTables::lobby) + // TODO check bevy_spacetimedb PR status + .add_view_with_pk(RemoteTables::view_hand, |p| p.id) // semicolon stopper ; @@ -87,104 +89,70 @@ fn subscriptions(stdb: SpacetimeDB) { .on_applied(|_| trace!("made all subs!")) .on_error(|_, err| error!("sub failed: {err}")) .subscribe([ - // TODO until views work + // TODO change these to sub/unsub based on being in lobby and some such format!( "SELECT * FROM player p WHERE p.identity = '{}'", stdb.identity() ), - "SELECT l.* FROM lobby l JOIN player p ON l.host_player_id = p.id".to_string(), + "SELECT l.* FROM lobby l JOIN player p ON l.id = p.lobby_id".to_string(), + "SELECT c.* FROM player_clock c JOIN player p ON c.player_id = p.id".to_string(), + "SELECT * FROM view_hand".to_string(), + "SELECT b.* FROM bot b JOIN lobby l ON l.id = b.lobby_id".to_string(), ]); // .subscribe_to_all_tables(); } -fn on_player_insert_update( - mut messages: ReadInsertUpdateMessage, +fn on_view_hand_insert_update( + stdb: SpacetimeDB, + mut messages: ReadInsertUpdateMessage, + mut commands: Commands, - - pond: Option>>, - hand: Option>>, - tiles: Query<(Entity, &TileId)>, + mut hand: Option>>, + tiles: Query<&Tile>, + mut next_turnstate: ResMut>, ) { - let hand = if hand.is_none() { - let hand = commands.spawn(Hand).id(); - commands.spawn(Pond); - hand - } else { - *hand.unwrap() - }; - let pond = if pond.is_none() { - let pond = commands.spawn(Pond).id(); - commands.spawn(Pond); - pond - } else { - *pond.unwrap() - }; - for msg in messages.read() { - /* match msg.new.turn_state { - jong_db::TurnState::None => {} - jong_db::TurnState::Tsumo => { - stdb.reducers().draw_tile().unwrap(); - } - jong_db::TurnState::Menzen => todo!(), - jong_db::TurnState::RiichiKan => todo!(), - jong_db::TurnState::RonChiiPonKan => { - stdb.reducers().skip_call().unwrap(); - } - jong_db::TurnState::End => todo!(), + if hand.is_none() { + let hand_tiles: Vec<_> = msg + .new + .hand + .iter() + .map(|dbt| commands.spawn((Tile::from(&dbt.tile), TileId(dbt.id))).id()) + .collect(); + commands.spawn(Hand).add_children(&hand_tiles); } - let hand_tiles: Vec<_> = msg - .new - .hand - .iter() - .map(|dbt| { - tiles - .iter() - .find_map(|(e, t)| if *t == TileId(dbt.id) { Some(e) } else { None }) - .or_else(|| Some(commands.spawn((Tile::from(&dbt.tile), TileId(dbt.id))).id())) - .unwrap() - }) - .collect(); - let pond_tiles: Vec<_> = msg - .new - .pond - .iter() - .map(|dbt| { - tiles - .iter() - .find_map(|(e, t)| if *t == TileId(dbt.id) { Some(e) } else { None }) - .expect(&format!( - "dealt tiles should still be around, couldn't find {:?}. Tiles: {:?}", - dbt, - tiles.iter().map(|(_, t)| t).collect::>() - )) - }) - .collect(); + // match msg.new.turn_state { + // jong_db::TurnState::None => todo!(), + // jong_db::TurnState::Tsumo => todo!(), + // jong_db::TurnState::Menzen => todo!(), + // jong_db::TurnState::RiichiKan => todo!(), + // jong_db::TurnState::RonChiiPonKan => todo!(), + // jong_db::TurnState::End => todo!(), + // } - debug!("hand_tiles: {hand_tiles:?}"); - - commands.entity(hand).replace_children(&hand_tiles); - commands.entity(pond).replace_children(&pond_tiles); - - // drawn tile is always a new tile to us until wall isn't fake - if let Some(dbt) = &msg.new.drawn_tile { - debug!("drew tile with id: {}", dbt.id); - commands.spawn((Tile::from(&dbt.tile), TileId(dbt.id), Drawn)); - } */ + next_turnstate.set(msg.new.turn_state.into()); } } +fn on_player_insert_update( + stdb: SpacetimeDB, + mut messages: ReadInsertUpdateMessage, + + mut commands: Commands, +) { + for msg in messages.read() {} +} + fn on_lobby_insert_update( stdb: SpacetimeDB, mut messages: ReadInsertUpdateMessage, commands: Commands, mut next_gamestate: ResMut>, - mut next_turnstate: ResMut>, ) { for msg in messages.read() { - // trace!("on_lobby_insert_update msg:\n{:#?}", msg.new); + trace!("on_lobby_insert_update msg:\n{:#?}", msg.new); let player = stdb .db() @@ -205,12 +173,10 @@ fn on_lobby_insert_update( stdb.reducers().add_bot(player.lobby_id).unwrap(); } stdb.reducers().set_ready(true).unwrap(); - // stdb.reducers().start_game().unwrap(); } } jong_db::GameState::Setup => { trace!("game entered setup"); - // stdb.reducers().shuffle_deal(player.lobby_id).unwrap(); } jong_db::GameState::Deal => { trace!("game entered deal"); diff --git a/jong/src/tui.rs b/jong/src/tui.rs index 9198051..4a82498 100644 --- a/jong/src/tui.rs +++ b/jong/src/tui.rs @@ -97,9 +97,8 @@ impl Plugin for TuiPlugin { fn discard_tile( stdb: SpacetimeDB, - mut selected: MessageReader, - mut commands: Commands, + mut selected: MessageReader, drawn: Single<(Entity, &TileId), With>, tiles: Query<&TileId>, ) { diff --git a/justfile b/justfile index 8f51801..4541442 100644 --- a/justfile +++ b/justfile @@ -8,8 +8,6 @@ default: just --list run-tui: - just spacetime_restart_dev - sleep 3sec cargo run -- run-tui update: @@ -27,3 +25,8 @@ spacetime_generate-bindings: spacetime_restart_dev: mprocs -s localhost:4050 --ctl $"({c: restart-proc, name: spacetimedb_dev} | to yaml)" + +rrt: + just spacetime_restart_dev + sleep 3sec + just run-tui