diff --git a/.helix/config.toml b/.helix/config.toml new file mode 100644 index 0000000..07545b2 --- /dev/null +++ b/.helix/config.toml @@ -0,0 +1,2 @@ +[editor] +workspace-lsp-roots = ["jongline"] diff --git a/Cargo.lock b/Cargo.lock index 3603b25..8141aca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.3.4", "once_cell", "version_check", "zerocopy", @@ -504,7 +504,7 @@ dependencies = [ "ron", "serde", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "thread_local", "tracing", "uuid", @@ -560,7 +560,7 @@ dependencies = [ "ctrlc", "downcast-rs 2.0.2", "log", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", "wasm-bindgen", "web-sys", @@ -598,7 +598,7 @@ dependencies = [ "ron", "serde", "stackfuture", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "uuid", "wasm-bindgen", @@ -658,7 +658,7 @@ dependencies = [ "downcast-rs 2.0.2", "serde", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "wgpu-types", ] @@ -674,7 +674,7 @@ dependencies = [ "derive_more 2.1.1", "encase", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "wgpu-types", ] @@ -703,7 +703,7 @@ dependencies = [ "nonmax", "radsort", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", ] @@ -769,7 +769,7 @@ dependencies = [ "serde", "slotmap", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] @@ -807,7 +807,7 @@ dependencies = [ "bevy_platform", "bevy_time", "gilrs", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", ] @@ -882,7 +882,7 @@ dependencies = [ "serde", "serde_json", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", ] @@ -910,7 +910,7 @@ dependencies = [ "rectangle-pack", "ruzstd", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "wgpu-types", ] @@ -929,7 +929,7 @@ dependencies = [ "derive_more 2.1.1", "log", "smol_str", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -946,7 +946,7 @@ dependencies = [ "bevy_reflect", "bevy_window", "log", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -1069,7 +1069,7 @@ dependencies = [ "rand_distr", "serde", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "variadics_please", ] @@ -1093,7 +1093,7 @@ dependencies = [ "bytemuck", "derive_more 2.1.1", "hexasphere", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "wgpu-types", ] @@ -1136,7 +1136,7 @@ dependencies = [ "offset-allocator", "smallvec", "static_assertions", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", ] @@ -1173,7 +1173,7 @@ dependencies = [ "critical-section", "foldhash 0.2.0", "futures-channel", - "getrandom", + "getrandom 0.3.4", "hashbrown 0.16.1", "js-sys", "portable-atomic", @@ -1211,7 +1211,7 @@ dependencies = [ "nonmax", "radsort", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", ] @@ -1255,7 +1255,7 @@ dependencies = [ "serde", "smallvec", "smol_str", - "thiserror 2.0.17", + "thiserror 2.0.18", "uuid", "variadics_please", "wgpu-types", @@ -1316,7 +1316,7 @@ dependencies = [ "offset-allocator", "send_wrapper", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "variadics_please", "wasm-bindgen", @@ -1353,7 +1353,7 @@ dependencies = [ "bevy_utils", "derive_more 2.1.1", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "uuid", ] @@ -1369,7 +1369,7 @@ dependencies = [ "naga", "naga_oil", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "wgpu-types", ] @@ -1520,7 +1520,7 @@ dependencies = [ "serde", "smallvec", "sys-locale", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "wgpu-types", ] @@ -1555,7 +1555,7 @@ dependencies = [ "bevy_utils", "derive_more 2.1.1", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -1586,7 +1586,7 @@ dependencies = [ "derive_more 2.1.1", "smallvec", "taffy", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "uuid", ] @@ -2670,7 +2670,7 @@ dependencies = [ "const_panic", "encase_derive", "glam", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -2753,9 +2753,9 @@ dependencies = [ [[package]] name = "euclid" -version = "0.22.11" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad9cdb4b747e485a12abb0e6566612956c7a1bafa3bdb8d682c5b6d403589e48" +checksum = "df61bf483e837f88d5c2291dcf55c67be7e676b3a51acc48db3a7b163b91ed63" dependencies = [ "num-traits", ] @@ -3084,6 +3084,17 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -3722,7 +3733,7 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ - "getrandom", + "getrandom 0.3.4", "libc", ] @@ -3734,6 +3745,7 @@ dependencies = [ "bevy_ratatui", "bevy_spacetimedb", "clap", + "jongline", "log", "rand 0.9.2", "ratatui", @@ -3743,6 +3755,14 @@ dependencies = [ "tui-logger", ] +[[package]] +name = "jongline" +version = "0.1.0" +dependencies = [ + "log", + "spacetimedb", +] + [[package]] name = "js-sys" version = "0.3.85" @@ -3761,7 +3781,7 @@ checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b" dependencies = [ "hashbrown 0.16.1", "portable-atomic", - "thiserror 2.0.17", + "thiserror 2.0.18", ] [[package]] @@ -4065,7 +4085,7 @@ dependencies = [ "pp-rs", "rustc-hash 1.1.0", "spirv", - "thiserror 2.0.17", + "thiserror 2.0.18", "unicode-ident", ] @@ -4081,7 +4101,7 @@ dependencies = [ "naga", "regex", "rustc-hash 1.1.0", - "thiserror 2.0.17", + "thiserror 2.0.18", "tracing", "unicode-ident", ] @@ -4960,9 +4980,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -5014,9 +5034,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -5039,6 +5059,8 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ + "libc", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] @@ -5048,10 +5070,20 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "rand_chacha", + "rand_chacha 0.9.0", "rand_core 0.9.5", ] +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.9.0" @@ -5067,6 +5099,9 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] [[package]] name = "rand_core" @@ -5074,7 +5109,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ - "getrandom", + "getrandom 0.3.4", ] [[package]] @@ -5127,7 +5162,7 @@ dependencies = [ "kasuari", "lru", "strum 0.27.2", - "thiserror 2.0.17", + "thiserror 2.0.18", "unicode-segmentation", "unicode-truncate", "unicode-width", @@ -5781,6 +5816,28 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "spacetimedb" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83af98280374b59796296f512f7855fd19e19240a358bb7706a54f1c4e4e7dff" +dependencies = [ + "anyhow", + "bytemuck", + "bytes", + "derive_more 0.99.20", + "getrandom 0.2.17", + "http", + "log", + "rand 0.8.5", + "scoped-tls", + "serde_json", + "spacetimedb-bindings-macro", + "spacetimedb-bindings-sys", + "spacetimedb-lib", + "spacetimedb-primitives", +] + [[package]] name = "spacetimedb-bindings-macro" version = "1.11.3" @@ -5795,6 +5852,15 @@ dependencies = [ "syn 2.0.114", ] +[[package]] +name = "spacetimedb-bindings-sys" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0d30e1655731b1564b7094a6213ef6c354ea920e3c04424e55ad377a1bc3e2" +dependencies = [ + "spacetimedb-primitives", +] + [[package]] name = "spacetimedb-client-api-messages" version = "1.11.3" @@ -6125,7 +6191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.3.4", "once_cell", "rustix 1.1.3", "windows-sys 0.61.2", @@ -6214,11 +6280,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.17", + "thiserror-impl 2.0.18", ] [[package]] @@ -6234,9 +6300,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", @@ -6531,9 +6597,9 @@ checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" [[package]] name = "tui-logger" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01685c50c8f7b25e67b538f132f12fffeb524cc75cf3e14f0946bc5563b455ea" +checksum = "9384df20a5244a6ab204bc4b6959b41f37f0ee7b5e0f2feb7a8a78f58e684d06" dependencies = [ "chrono", "env_filter", @@ -6560,7 +6626,7 @@ dependencies = [ "native-tls", "rand 0.9.2", "sha1", - "thiserror 2.0.17", + "thiserror 2.0.18", "url", "utf-8", ] @@ -6703,7 +6769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ "atomic", - "getrandom", + "getrandom 0.3.4", "js-sys", "serde_core", "wasm-bindgen", @@ -6981,7 +7047,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" dependencies = [ - "getrandom", + "getrandom 0.3.4", "mac_address", "sha2", "thiserror 1.0.69", @@ -7087,7 +7153,7 @@ dependencies = [ "raw-window-handle", "rustc-hash 1.1.0", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "wgpu-core-deps-apple", "wgpu-core-deps-wasm", "wgpu-core-deps-windows-linux-android", @@ -7162,7 +7228,7 @@ dependencies = [ "raw-window-handle", "renderdoc-sys", "smallvec", - "thiserror 2.0.17", + "thiserror 2.0.18", "wasm-bindgen", "web-sys", "wgpu-types", @@ -7181,7 +7247,7 @@ dependencies = [ "js-sys", "log", "serde", - "thiserror 2.0.17", + "thiserror 2.0.18", "web-sys", ] @@ -7986,6 +8052,6 @@ dependencies = [ [[package]] name = "zmij" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" +checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65" diff --git a/Cargo.toml b/Cargo.toml index fafbeb5..aa55a94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,30 +1,6 @@ -[package] -name = "jong" -version = "0.1.0" -edition = "2024" -# license = "Source-First-1.1" # pending crates.io support -license-file = "LICENSE.typ" -description = "riichi mahjong" -readme = false - -[lib] - -[dependencies] -bevy = { version = "0.17.3", features = ["dynamic_linking"] } -# bevy_ratatui = { git = "https://github.com/kenianbei/bevy_ratatui.git", rev = "e4b022308e08ab360ef89eca8e9f8b1c969e9a56" } -bevy_ratatui = { path = "/home/tao/clones/bevy_ratatui" } -bevy_spacetimedb = "0.7" -clap = { version = "4.5.54", features = ["derive"] } -log = { version = "0.4.29", features = [ - "release_max_level_error", - "max_level_trace", -] } -rand = "0.9.2" -ratatui = "0.30.0" -strum = { version = "0.27.2", features = ["derive"] } -tracing = "0.1.44" -tracing-subscriber = "0.3.22" -tui-logger = { version = "0.18.0", features = ["tracing-support", "crossterm"] } +[workspace] +resolver = "3" +members = ["jong", "jongline"] [profile.dev] opt-level = 1 diff --git a/jong/Cargo.toml b/jong/Cargo.toml new file mode 100644 index 0000000..8ab386e --- /dev/null +++ b/jong/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "jong" +version = "0.1.0" +edition = "2024" +# license = "Source-First-1.1" # pending crates.io support +license-file = "LICENSE.typ" +description = "riichi mahjong" +readme = false + +[lib] + +[dependencies] +bevy = { version = "0.17.3", features = ["dynamic_linking"] } +# bevy_ratatui = { git = "https://github.com/kenianbei/bevy_ratatui.git", rev = "e4b022308e08ab360ef89eca8e9f8b1c969e9a56" } +bevy_ratatui = { path = "/home/tao/clones/bevy_ratatui" } +bevy_spacetimedb = "0.7" +clap = { version = "4.5.54", features = ["derive"] } +jongline = { version = "0.1.0", path = "../jongline" } +log = { version = "0.4.29", features = [ + "release_max_level_error", + "max_level_trace", +] } +rand = "0.9.2" +ratatui = "0.30.0" +strum = { version = "0.27.2", features = ["derive"] } +tracing = "0.1.44" +tracing-subscriber = "0.3.22" +tui-logger = { version = "0.18.0", features = ["tracing-support", "crossterm"] } diff --git a/src/game.rs b/jong/src/game.rs similarity index 100% rename from src/game.rs rename to jong/src/game.rs diff --git a/src/game/hand.rs b/jong/src/game/hand.rs similarity index 100% rename from src/game/hand.rs rename to jong/src/game/hand.rs diff --git a/src/game/player.rs b/jong/src/game/player.rs similarity index 100% rename from src/game/player.rs rename to jong/src/game/player.rs diff --git a/src/game/round.rs b/jong/src/game/round.rs similarity index 100% rename from src/game/round.rs rename to jong/src/game/round.rs diff --git a/src/game/wall.rs b/jong/src/game/wall.rs similarity index 100% rename from src/game/wall.rs rename to jong/src/game/wall.rs diff --git a/src/gui/mod.rs b/jong/src/gui/mod.rs similarity index 100% rename from src/gui/mod.rs rename to jong/src/gui/mod.rs diff --git a/src/jongline_bindings/add_reducer.rs b/jong/src/jongline_bindings/create_player_reducer.rs similarity index 51% rename from src/jongline_bindings/add_reducer.rs rename to jong/src/jongline_bindings/create_player_reducer.rs index 5bfecc3..6271888 100644 --- a/src/jongline_bindings/add_reducer.rs +++ b/jong/src/jongline_bindings/create_player_reducer.rs @@ -6,65 +6,68 @@ 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 AddArgs { - pub name: String, +pub(super) struct CreatePlayerArgs { + pub username: String, } -impl From for super::Reducer { - fn from(args: AddArgs) -> Self { - Self::Add { name: args.name } +impl From for super::Reducer { + fn from(args: CreatePlayerArgs) -> Self { + Self::CreatePlayer { + username: args.username, + } } } -impl __sdk::InModule for AddArgs { +impl __sdk::InModule for CreatePlayerArgs { type Module = super::RemoteModule; } -pub struct AddCallbackId(__sdk::CallbackId); +pub struct CreatePlayerCallbackId(__sdk::CallbackId); #[allow(non_camel_case_types)] -/// Extension trait for access to the reducer `add`. +/// Extension trait for access to the reducer `create_player`. /// /// Implemented for [`super::RemoteReducers`]. -pub trait add { - /// Request that the remote module invoke the reducer `add` to run as soon as possible. +pub trait create_player { + /// Request that the remote module invoke the reducer `create_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_add`] callbacks. - fn add(&self, name: String) -> __sdk::Result<()>; - /// Register a callback to run whenever we are notified of an invocation of the reducer `add`. + /// and its status can be observed by listening for [`Self::on_create_player`] callbacks. + fn create_player(&self, username: String) -> __sdk::Result<()>; + /// Register a callback to run whenever we are notified of an invocation of the reducer `create_player`. /// /// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`] /// to determine the reducer's status. /// - /// The returned [`AddCallbackId`] can be passed to [`Self::remove_on_add`] + /// The returned [`CreatePlayerCallbackId`] can be passed to [`Self::remove_on_create_player`] /// to cancel the callback. - fn on_add( + fn on_create_player( &self, callback: impl FnMut(&super::ReducerEventContext, &String) + Send + 'static, - ) -> AddCallbackId; - /// Cancel a callback previously registered by [`Self::on_add`], + ) -> CreatePlayerCallbackId; + /// Cancel a callback previously registered by [`Self::on_create_player`], /// causing it not to run in the future. - fn remove_on_add(&self, callback: AddCallbackId); + fn remove_on_create_player(&self, callback: CreatePlayerCallbackId); } -impl add for super::RemoteReducers { - fn add(&self, name: String) -> __sdk::Result<()> { - self.imp.call_reducer("add", AddArgs { name }) +impl create_player for super::RemoteReducers { + fn create_player(&self, username: String) -> __sdk::Result<()> { + self.imp + .call_reducer("create_player", CreatePlayerArgs { username }) } - fn on_add( + fn on_create_player( &self, mut callback: impl FnMut(&super::ReducerEventContext, &String) + Send + 'static, - ) -> AddCallbackId { - AddCallbackId(self.imp.on_reducer( - "add", + ) -> CreatePlayerCallbackId { + CreatePlayerCallbackId(self.imp.on_reducer( + "create_player", Box::new(move |ctx: &super::ReducerEventContext| { #[allow(irrefutable_let_patterns)] let super::ReducerEventContext { event: __sdk::ReducerEvent { - reducer: super::Reducer::Add { name }, + reducer: super::Reducer::CreatePlayer { username }, .. }, .. @@ -72,31 +75,31 @@ impl add for super::RemoteReducers { else { unreachable!() }; - callback(ctx, name) + callback(ctx, username) }), )) } - fn remove_on_add(&self, callback: AddCallbackId) { - self.imp.remove_on_reducer("add", callback.0) + fn remove_on_create_player(&self, callback: CreatePlayerCallbackId) { + self.imp.remove_on_reducer("create_player", callback.0) } } #[allow(non_camel_case_types)] #[doc(hidden)] -/// Extension trait for setting the call-flags for the reducer `add`. +/// Extension trait for setting the call-flags for the reducer `create_player`. /// /// Implemented for [`super::SetReducerFlags`]. /// /// This type is currently unstable and may be removed without a major version bump. -pub trait set_flags_for_add { - /// Set the call-reducer flags for the reducer `add` to `flags`. +pub trait set_flags_for_create_player { + /// Set the call-reducer flags for the reducer `create_player` to `flags`. /// /// This type is currently unstable and may be removed without a major version bump. - fn add(&self, flags: __ws::CallReducerFlags); + fn create_player(&self, flags: __ws::CallReducerFlags); } -impl set_flags_for_add for super::SetReducerFlags { - fn add(&self, flags: __ws::CallReducerFlags) { - self.imp.set_call_reducer_flags("add", flags); +impl set_flags_for_create_player for super::SetReducerFlags { + fn create_player(&self, flags: __ws::CallReducerFlags) { + self.imp.set_call_reducer_flags("create_player", flags); } } diff --git a/jong/src/jongline_bindings/drawn_table.rs b/jong/src/jongline_bindings/drawn_table.rs new file mode 100644 index 0000000..2df1f4b --- /dev/null +++ b/jong/src/jongline_bindings/drawn_table.rs @@ -0,0 +1,95 @@ +// 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::drawn_type::Drawn; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `drawn`. +/// +/// Obtain a handle from the [`DrawnTableAccess::drawn`] method on [`super::RemoteTables`], +/// like `ctx.db.drawn()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.drawn().on_insert(...)`. +pub struct DrawnTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `drawn`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait DrawnTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`DrawnTableHandle`], which mediates access to the table `drawn`. + fn drawn(&self) -> DrawnTableHandle<'_>; +} + +impl DrawnTableAccess for super::RemoteTables { + fn drawn(&self) -> DrawnTableHandle<'_> { + DrawnTableHandle { + imp: self.imp.get_table::("drawn"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct DrawnInsertCallbackId(__sdk::CallbackId); +pub struct DrawnDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for DrawnTableHandle<'ctx> { + type Row = Drawn; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = DrawnInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> DrawnInsertCallbackId { + DrawnInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: DrawnInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = DrawnDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> DrawnDeleteCallbackId { + DrawnDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: DrawnDeleteCallbackId) { + 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::("drawn"); +} + +#[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() + }) +} diff --git a/jong/src/jongline_bindings/drawn_type.rs b/jong/src/jongline_bindings/drawn_type.rs new file mode 100644 index 0000000..c443a03 --- /dev/null +++ b/jong/src/jongline_bindings/drawn_type.rs @@ -0,0 +1,13 @@ +// 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 Drawn {} + +impl __sdk::InModule for Drawn { + type Module = super::RemoteModule; +} diff --git a/jong/src/jongline_bindings/hand_table.rs b/jong/src/jongline_bindings/hand_table.rs new file mode 100644 index 0000000..9e15c00 --- /dev/null +++ b/jong/src/jongline_bindings/hand_table.rs @@ -0,0 +1,95 @@ +// 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::hand_type::Hand; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `hand`. +/// +/// Obtain a handle from the [`HandTableAccess::hand`] method on [`super::RemoteTables`], +/// like `ctx.db.hand()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.hand().on_insert(...)`. +pub struct HandTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `hand`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait HandTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`HandTableHandle`], which mediates access to the table `hand`. + fn hand(&self) -> HandTableHandle<'_>; +} + +impl HandTableAccess for super::RemoteTables { + fn hand(&self) -> HandTableHandle<'_> { + HandTableHandle { + imp: self.imp.get_table::("hand"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct HandInsertCallbackId(__sdk::CallbackId); +pub struct HandDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for HandTableHandle<'ctx> { + type Row = Hand; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = HandInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> HandInsertCallbackId { + HandInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: HandInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = HandDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> HandDeleteCallbackId { + HandDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: HandDeleteCallbackId) { + 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::("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() + }) +} diff --git a/jong/src/jongline_bindings/hand_type.rs b/jong/src/jongline_bindings/hand_type.rs new file mode 100644 index 0000000..f2bbfd2 --- /dev/null +++ b/jong/src/jongline_bindings/hand_type.rs @@ -0,0 +1,13 @@ +// 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 Hand {} + +impl __sdk::InModule for Hand { + type Module = super::RemoteModule; +} diff --git a/src/jongline_bindings/identity_connected_reducer.rs b/jong/src/jongline_bindings/identity_connected_reducer.rs similarity index 100% rename from src/jongline_bindings/identity_connected_reducer.rs rename to jong/src/jongline_bindings/identity_connected_reducer.rs diff --git a/src/jongline_bindings/identity_disconnected_reducer.rs b/jong/src/jongline_bindings/identity_disconnected_reducer.rs similarity index 100% rename from src/jongline_bindings/identity_disconnected_reducer.rs rename to jong/src/jongline_bindings/identity_disconnected_reducer.rs diff --git a/src/jongline_bindings/mod.rs b/jong/src/jongline_bindings/mod.rs similarity index 90% rename from src/jongline_bindings/mod.rs rename to jong/src/jongline_bindings/mod.rs index 267c99c..00aa7f7 100644 --- a/src/jongline_bindings/mod.rs +++ b/jong/src/jongline_bindings/mod.rs @@ -6,21 +6,39 @@ #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -pub mod add_reducer; +pub mod create_player_reducer; +pub mod drawn_table; +pub mod drawn_type; +pub mod hand_table; +pub mod hand_type; pub mod identity_connected_reducer; pub mod identity_disconnected_reducer; +pub mod player_table; pub mod player_type; -pub mod players_table; +pub mod table_table; +pub mod table_type; +pub mod wall_table; +pub mod wall_type; -pub use add_reducer::{add, set_flags_for_add, AddCallbackId}; +pub use create_player_reducer::{ + create_player, set_flags_for_create_player, CreatePlayerCallbackId, +}; +pub use drawn_table::*; +pub use drawn_type::Drawn; +pub use hand_table::*; +pub use hand_type::Hand; pub use identity_connected_reducer::{ identity_connected, set_flags_for_identity_connected, IdentityConnectedCallbackId, }; pub use identity_disconnected_reducer::{ identity_disconnected, set_flags_for_identity_disconnected, IdentityDisconnectedCallbackId, }; +pub use player_table::*; pub use player_type::Player; -pub use players_table::*; +pub use table_table::*; +pub use table_type::Table; +pub use wall_table::*; +pub use wall_type::Wall; #[derive(Clone, PartialEq, Debug)] @@ -30,7 +48,7 @@ pub use players_table::*; /// to indicate which reducer caused the event. pub enum Reducer { - Add { name: String }, + CreatePlayer { username: String }, IdentityConnected, IdentityDisconnected, } @@ -42,7 +60,7 @@ impl __sdk::InModule for Reducer { impl __sdk::Reducer for Reducer { fn reducer_name(&self) -> &'static str { match self { - Reducer::Add { .. } => "add", + Reducer::CreatePlayer { .. } => "create_player", Reducer::IdentityConnected => "identity_connected", Reducer::IdentityDisconnected => "identity_disconnected", _ => unreachable!(), @@ -53,9 +71,10 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { type Error = __sdk::Error; fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result { match &value.reducer_name[..] { - "add" => { - Ok(__sdk::parse_reducer_args::("add", &value.args)?.into()) - } + "create_player" => Ok(__sdk::parse_reducer_args::< + create_player_reducer::CreatePlayerArgs, + >("create_player", &value.args)? + .into()), "identity_connected" => Ok(__sdk::parse_reducer_args::< identity_connected_reducer::IdentityConnectedArgs, >("identity_connected", &value.args)? @@ -78,7 +97,11 @@ impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer { #[allow(non_snake_case)] #[doc(hidden)] pub struct DbUpdate { - players: __sdk::TableUpdate, + drawn: __sdk::TableUpdate, + hand: __sdk::TableUpdate, + player: __sdk::TableUpdate, + table: __sdk::TableUpdate, + wall: __sdk::TableUpdate, } impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { @@ -87,9 +110,21 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate { let mut db_update = DbUpdate::default(); for table_update in raw.tables { match &table_update.table_name[..] { - "players" => db_update - .players - .append(players_table::parse_table_update(table_update)?), + "drawn" => db_update + .drawn + .append(drawn_table::parse_table_update(table_update)?), + "hand" => db_update + .hand + .append(hand_table::parse_table_update(table_update)?), + "player" => db_update + .player + .append(player_table::parse_table_update(table_update)?), + "table" => db_update + .table + .append(table_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( @@ -116,7 +151,11 @@ impl __sdk::DbUpdate for DbUpdate { ) -> AppliedDiff<'_> { let mut diff = AppliedDiff::default(); - diff.players = cache.apply_diff_to_table::("players", &self.players); + diff.drawn = cache.apply_diff_to_table::("drawn", &self.drawn); + diff.hand = cache.apply_diff_to_table::("hand", &self.hand); + diff.player = cache.apply_diff_to_table::("player", &self.player); + diff.table = cache.apply_diff_to_table::
("table", &self.table); + diff.wall = cache.apply_diff_to_table::("wall", &self.wall); diff } @@ -126,7 +165,11 @@ impl __sdk::DbUpdate for DbUpdate { #[allow(non_snake_case)] #[doc(hidden)] pub struct AppliedDiff<'r> { - players: __sdk::TableAppliedDiff<'r, Player>, + drawn: __sdk::TableAppliedDiff<'r, Drawn>, + hand: __sdk::TableAppliedDiff<'r, Hand>, + player: __sdk::TableAppliedDiff<'r, Player>, + table: __sdk::TableAppliedDiff<'r, Table>, + wall: __sdk::TableAppliedDiff<'r, Wall>, __unused: std::marker::PhantomData<&'r ()>, } @@ -140,7 +183,11 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> { event: &EventContext, callbacks: &mut __sdk::DbCallbacks, ) { - callbacks.invoke_table_row_callbacks::("players", &self.players, event); + callbacks.invoke_table_row_callbacks::("drawn", &self.drawn, event); + callbacks.invoke_table_row_callbacks::("hand", &self.hand, event); + callbacks.invoke_table_row_callbacks::("player", &self.player, event); + callbacks.invoke_table_row_callbacks::
("table", &self.table, event); + callbacks.invoke_table_row_callbacks::("wall", &self.wall, event); } } @@ -860,6 +907,10 @@ impl __sdk::SpacetimeModule for RemoteModule { type SubscriptionHandle = SubscriptionHandle; fn register_tables(client_cache: &mut __sdk::ClientCache) { - players_table::register_table(client_cache); + drawn_table::register_table(client_cache); + hand_table::register_table(client_cache); + player_table::register_table(client_cache); + table_table::register_table(client_cache); + wall_table::register_table(client_cache); } } diff --git a/src/jongline_bindings/players_table.rs b/jong/src/jongline_bindings/player_table.rs similarity index 57% rename from src/jongline_bindings/players_table.rs rename to jong/src/jongline_bindings/player_table.rs index e7a5d40..3014fc8 100644 --- a/src/jongline_bindings/players_table.rs +++ b/jong/src/jongline_bindings/player_table.rs @@ -5,42 +5,42 @@ use super::player_type::Player; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; -/// Table handle for the table `players`. +/// Table handle for the table `player`. /// -/// Obtain a handle from the [`PlayersTableAccess::players`] method on [`super::RemoteTables`], -/// like `ctx.db.players()`. +/// Obtain a handle from the [`PlayerTableAccess::player`] method on [`super::RemoteTables`], +/// like `ctx.db.player()`. /// /// Users are encouraged not to explicitly reference this type, /// but to directly chain method calls, -/// like `ctx.db.players().on_insert(...)`. -pub struct PlayersTableHandle<'ctx> { +/// like `ctx.db.player().on_insert(...)`. +pub struct PlayerTableHandle<'ctx> { imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } #[allow(non_camel_case_types)] -/// Extension trait for access to the table `players`. +/// Extension trait for access to the table `player`. /// /// Implemented for [`super::RemoteTables`]. -pub trait PlayersTableAccess { +pub trait PlayerTableAccess { #[allow(non_snake_case)] - /// Obtain a [`PlayersTableHandle`], which mediates access to the table `players`. - fn players(&self) -> PlayersTableHandle<'_>; + /// Obtain a [`PlayerTableHandle`], which mediates access to the table `player`. + fn player(&self) -> PlayerTableHandle<'_>; } -impl PlayersTableAccess for super::RemoteTables { - fn players(&self) -> PlayersTableHandle<'_> { - PlayersTableHandle { - imp: self.imp.get_table::("players"), +impl PlayerTableAccess for super::RemoteTables { + fn player(&self) -> PlayerTableHandle<'_> { + PlayerTableHandle { + imp: self.imp.get_table::("player"), ctx: std::marker::PhantomData, } } } -pub struct PlayersInsertCallbackId(__sdk::CallbackId); -pub struct PlayersDeleteCallbackId(__sdk::CallbackId); +pub struct PlayerInsertCallbackId(__sdk::CallbackId); +pub struct PlayerDeleteCallbackId(__sdk::CallbackId); -impl<'ctx> __sdk::Table for PlayersTableHandle<'ctx> { +impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> { type Row = Player; type EventContext = super::EventContext; @@ -51,36 +51,36 @@ impl<'ctx> __sdk::Table for PlayersTableHandle<'ctx> { self.imp.iter() } - type InsertCallbackId = PlayersInsertCallbackId; + type InsertCallbackId = PlayerInsertCallbackId; fn on_insert( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> PlayersInsertCallbackId { - PlayersInsertCallbackId(self.imp.on_insert(Box::new(callback))) + ) -> PlayerInsertCallbackId { + PlayerInsertCallbackId(self.imp.on_insert(Box::new(callback))) } - fn remove_on_insert(&self, callback: PlayersInsertCallbackId) { + fn remove_on_insert(&self, callback: PlayerInsertCallbackId) { self.imp.remove_on_insert(callback.0) } - type DeleteCallbackId = PlayersDeleteCallbackId; + type DeleteCallbackId = PlayerDeleteCallbackId; fn on_delete( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, - ) -> PlayersDeleteCallbackId { - PlayersDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + ) -> PlayerDeleteCallbackId { + PlayerDeleteCallbackId(self.imp.on_delete(Box::new(callback))) } - fn remove_on_delete(&self, callback: PlayersDeleteCallbackId) { + fn remove_on_delete(&self, callback: PlayerDeleteCallbackId) { 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::("players"); + let _table = client_cache.get_or_make_table::("player"); } #[doc(hidden)] diff --git a/src/jongline_bindings/player_type.rs b/jong/src/jongline_bindings/player_type.rs similarity index 81% rename from src/jongline_bindings/player_type.rs rename to jong/src/jongline_bindings/player_type.rs index bf9b46a..871ae30 100644 --- a/src/jongline_bindings/player_type.rs +++ b/jong/src/jongline_bindings/player_type.rs @@ -7,7 +7,9 @@ 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 name: String, + pub username: String, + pub identity: __sdk::Identity, + pub connection_id: __sdk::ConnectionId, } impl __sdk::InModule for Player { diff --git a/jong/src/jongline_bindings/table_table.rs b/jong/src/jongline_bindings/table_table.rs new file mode 100644 index 0000000..9b05b54 --- /dev/null +++ b/jong/src/jongline_bindings/table_table.rs @@ -0,0 +1,97 @@ +// 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::hand_type::Hand; +use super::player_type::Player; +use super::table_type::Table; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `table`. +/// +/// Obtain a handle from the [`TableTableAccess::table`] method on [`super::RemoteTables`], +/// like `ctx.db.table()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.table().on_insert(...)`. +pub struct TableTableHandle<'ctx> { + imp: __sdk::TableHandle
, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `table`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait TableTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`TableTableHandle`], which mediates access to the table `table`. + fn table(&self) -> TableTableHandle<'_>; +} + +impl TableTableAccess for super::RemoteTables { + fn table(&self) -> TableTableHandle<'_> { + TableTableHandle { + imp: self.imp.get_table::
("table"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct TableInsertCallbackId(__sdk::CallbackId); +pub struct TableDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for TableTableHandle<'ctx> { + type Row = Table; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = TableInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> TableInsertCallbackId { + TableInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: TableInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = TableDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> TableDeleteCallbackId { + TableDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: TableDeleteCallbackId) { + 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::
("table"); +} + +#[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() + }) +} diff --git a/jong/src/jongline_bindings/table_type.rs b/jong/src/jongline_bindings/table_type.rs new file mode 100644 index 0000000..4d03385 --- /dev/null +++ b/jong/src/jongline_bindings/table_type.rs @@ -0,0 +1,19 @@ +// 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::hand_type::Hand; +use super::player_type::Player; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct Table { + pub players: Player, + pub hands: Vec, +} + +impl __sdk::InModule for Table { + type Module = super::RemoteModule; +} diff --git a/jong/src/jongline_bindings/wall_table.rs b/jong/src/jongline_bindings/wall_table.rs new file mode 100644 index 0000000..8657bf9 --- /dev/null +++ b/jong/src/jongline_bindings/wall_table.rs @@ -0,0 +1,95 @@ +// 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::wall_type::Wall; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `wall`. +/// +/// Obtain a handle from the [`WallTableAccess::wall`] method on [`super::RemoteTables`], +/// like `ctx.db.wall()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.wall().on_insert(...)`. +pub struct WallTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `wall`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait WallTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`WallTableHandle`], which mediates access to the table `wall`. + fn wall(&self) -> WallTableHandle<'_>; +} + +impl WallTableAccess for super::RemoteTables { + fn wall(&self) -> WallTableHandle<'_> { + WallTableHandle { + imp: self.imp.get_table::("wall"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct WallInsertCallbackId(__sdk::CallbackId); +pub struct WallDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for WallTableHandle<'ctx> { + type Row = Wall; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = WallInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> WallInsertCallbackId { + WallInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: WallInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = WallDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> WallDeleteCallbackId { + WallDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: WallDeleteCallbackId) { + 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::("wall"); +} + +#[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() + }) +} diff --git a/jong/src/jongline_bindings/wall_type.rs b/jong/src/jongline_bindings/wall_type.rs new file mode 100644 index 0000000..2056ff5 --- /dev/null +++ b/jong/src/jongline_bindings/wall_type.rs @@ -0,0 +1,13 @@ +// 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 Wall {} + +impl __sdk::InModule for Wall { + type Module = super::RemoteModule; +} diff --git a/src/lib.rs b/jong/src/lib.rs similarity index 100% rename from src/lib.rs rename to jong/src/lib.rs diff --git a/src/main.rs b/jong/src/main.rs similarity index 100% rename from src/main.rs rename to jong/src/main.rs diff --git a/src/tile.rs b/jong/src/tile.rs similarity index 100% rename from src/tile.rs rename to jong/src/tile.rs diff --git a/src/tui.rs b/jong/src/tui.rs similarity index 100% rename from src/tui.rs rename to jong/src/tui.rs diff --git a/src/tui/input.rs b/jong/src/tui/input.rs similarity index 100% rename from src/tui/input.rs rename to jong/src/tui/input.rs diff --git a/src/tui/input/keyboard.rs b/jong/src/tui/input/keyboard.rs similarity index 100% rename from src/tui/input/keyboard.rs rename to jong/src/tui/input/keyboard.rs diff --git a/src/tui/input/mouse.rs b/jong/src/tui/input/mouse.rs similarity index 100% rename from src/tui/input/mouse.rs rename to jong/src/tui/input/mouse.rs diff --git a/src/tui/layout.rs b/jong/src/tui/layout.rs similarity index 100% rename from src/tui/layout.rs rename to jong/src/tui/layout.rs diff --git a/src/tui/render.rs b/jong/src/tui/render.rs similarity index 100% rename from src/tui/render.rs rename to jong/src/tui/render.rs diff --git a/src/yakus.rs b/jong/src/yakus.rs similarity index 100% rename from src/yakus.rs rename to jong/src/yakus.rs diff --git a/jongline/Cargo.lock b/jongline/Cargo.lock deleted file mode 100644 index 8ea10d5..0000000 --- a/jongline/Cargo.lock +++ /dev/null @@ -1,726 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "anyhow" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" - -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits", -] - -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "bitflags" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" - -[[package]] -name = "blake3" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2468ef7d57b3fb7e16b576e8377cdbde2320c60e1491e961d11da40fc4f02a2d" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "cpufeatures", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bytemuck" -version = "1.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" - -[[package]] -name = "bytes" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" - -[[package]] -name = "cc" -version = "1.2.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932" -dependencies = [ - "find-msvc-tools", - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "chrono" -version = "0.4.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" -dependencies = [ - "num-traits", -] - -[[package]] -name = "constant_time_eq" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "decorum" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "281759d3c8a14f5c3f0c49363be56810fcd7f910422f97f2db850c2920fde5cf" -dependencies = [ - "approx", - "num-traits", -] - -[[package]] -name = "derive_more" -version = "0.99.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "enum-as-inner" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ethnum" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca81e6b4777c89fd810c25a4be2b1bd93ea034fbe58e6a75216a34c6b82c539b" -dependencies = [ - "serde", -] - -[[package]] -name = "find-msvc-tools" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "http" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" -dependencies = [ - "bytes", - "itoa", -] - -[[package]] -name = "humantime" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" - -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" - -[[package]] -name = "jongline" -version = "0.1.0" -dependencies = [ - "log", - "spacetimedb", -] - -[[package]] -name = "keccak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "libc" -version = "0.2.180" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" - -[[package]] -name = "log" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" - -[[package]] -name = "memchr" -version = "2.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" - -[[package]] -name = "nohash-hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "second-stack" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4904c83c6e51f1b9b08bfa5a86f35a51798e8307186e6f5513852210a219c0bb" - -[[package]] -name = "semver" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" - -[[package]] -name = "serde" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" -dependencies = [ - "serde_core", -] - -[[package]] -name = "serde_core" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" -dependencies = [ - "itoa", - "memchr", - "serde", - "serde_core", - "zmij", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "spacetimedb" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83af98280374b59796296f512f7855fd19e19240a358bb7706a54f1c4e4e7dff" -dependencies = [ - "anyhow", - "bytemuck", - "bytes", - "derive_more", - "getrandom 0.2.17", - "http", - "log", - "rand 0.8.5", - "scoped-tls", - "serde_json", - "spacetimedb-bindings-macro", - "spacetimedb-bindings-sys", - "spacetimedb-lib", - "spacetimedb-primitives", -] - -[[package]] -name = "spacetimedb-bindings-macro" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d8dbedaa26e2e59d886a19bd2b784356d8d008274046f735c9185f9943bd912" -dependencies = [ - "heck 0.4.1", - "humantime", - "proc-macro2", - "quote", - "spacetimedb-primitives", - "syn", -] - -[[package]] -name = "spacetimedb-bindings-sys" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0d30e1655731b1564b7094a6213ef6c354ea920e3c04424e55ad377a1bc3e2" -dependencies = [ - "spacetimedb-primitives", -] - -[[package]] -name = "spacetimedb-lib" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f7284d48bcfddc7c091756c6d5d3cc9a847b95778c636fdd03b9538d74a57c7" -dependencies = [ - "anyhow", - "bitflags", - "blake3", - "chrono", - "derive_more", - "enum-as-inner", - "hex", - "itertools", - "log", - "spacetimedb-bindings-macro", - "spacetimedb-primitives", - "spacetimedb-sats", - "thiserror", -] - -[[package]] -name = "spacetimedb-primitives" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2dc124963dd166ecde2b4d8f0e5ed4cfd27a20d7f6bb9e84d7eff46cc520b5" -dependencies = [ - "bitflags", - "either", - "enum-as-inner", - "itertools", - "nohash-hasher", -] - -[[package]] -name = "spacetimedb-sats" -version = "1.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df06586ffc862efd795425854cc2469c561aca5b95f5df2212aa29ef14a56f8a" -dependencies = [ - "anyhow", - "arrayvec", - "bitflags", - "bytemuck", - "bytes", - "chrono", - "decorum", - "derive_more", - "enum-as-inner", - "ethnum", - "hex", - "itertools", - "rand 0.9.2", - "second-stack", - "sha3", - "smallvec", - "spacetimedb-bindings-macro", - "spacetimedb-primitives", - "thiserror", - "uuid", -] - -[[package]] -name = "syn" -version = "2.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - -[[package]] -name = "unicode-ident" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" - -[[package]] -name = "uuid" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" -dependencies = [ - "getrandom 0.3.4", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasip2" -version = "1.0.2+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" - -[[package]] -name = "zerocopy" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "zmij" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65" diff --git a/jongline/Cargo.toml b/jongline/Cargo.toml index 96c8641..7667498 100644 --- a/jongline/Cargo.toml +++ b/jongline/Cargo.toml @@ -11,3 +11,4 @@ crate-type = ["cdylib"] [dependencies] spacetimedb = "1.11.*" log = "0.4" +# jong = { version = "0.1.0", path = "../jong" } diff --git a/jongline/src/lib.rs b/jongline/src/lib.rs index 197576a..257a2f1 100644 --- a/jongline/src/lib.rs +++ b/jongline/src/lib.rs @@ -1,40 +1,61 @@ -use spacetimedb::{ReducerContext, Table}; +use spacetimedb::{reducer, ConnectionId, Identity, ReducerContext}; -#[spacetimedb::table(name = player, public)] +// use jong::tile::Tile; + +#[spacetimedb::table(name = player)] pub struct Player { - name: String, + username: String, + + identity: Identity, + connection_id: ConnectionId, } #[spacetimedb::table(name = table, public)] -pub struct Table {} +pub struct Table { + players: Player, + hands: Vec, +} #[spacetimedb::table(name = wall)] -pub struct Wall {} +pub struct Wall { + // tiles: Vec, +} #[spacetimedb::table(name = hand)] -pub struct Hand {} +pub struct Hand { + // hand: Vec, +} #[spacetimedb::table(name = drawn)] -pub struct Drawn {} +pub struct Drawn { + // tile: Tile, +} -#[spacetimedb::reducer(init)] +#[reducer(init)] pub fn init(_ctx: &ReducerContext) { // Called when the module is initially published } -#[spacetimedb::reducer(client_connected)] -pub fn identity_connected(_ctx: &ReducerContext) { +#[reducer(client_connected)] +pub fn identity_connected(ctx: &ReducerContext) { // Called everytime a new client connects } -#[spacetimedb::reducer(client_disconnected)] -pub fn identity_disconnected(_ctx: &ReducerContext) { - // Called everytime a client disconnects +// Called everytime a client disconnects +#[reducer(client_disconnected)] +pub fn identity_disconnected(ctx: &ReducerContext) { + // ctx.db.player().identity().delete(ctx.sender); } -#[spacetimedb::reducer] -pub fn add(ctx: &ReducerContext, name: String) { - ctx.db.players().insert(Player { name }); +#[reducer] +pub fn create_player(ctx: &ReducerContext, username: String) { + let connection_id = ctx.connection_id.unwrap(); + let identity = ctx.identity(); + // ctx.db.player().insert(Player { + // username, + // connection_id, + // identity, + // }); } // #[spacetimedb::reducer] diff --git a/justfile b/justfile index a2ca9f7..61f0930 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,7 @@ set shell := ["nu", "-c"] alias rt := run-tui +alias s := spacetime default: just --list @@ -12,5 +13,6 @@ update: cargo update nix flake update -generate-db-bindings: - spacetime generate --lang rust --out-dir src/jongline_bindings --project-path jongline +spacetime: + spacetime build --project-path jongline + spacetime generate --lang rust --project-path jongline --out-dir jong/src/jongline_bindings