upgrade spacetimedb to v2.0.1
This commit is contained in:
parent
5ebf3f6c05
commit
baab16144b
38 changed files with 481 additions and 1647 deletions
101
Cargo.lock
generated
101
Cargo.lock
generated
|
|
@ -2217,6 +2217,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.10.0"
|
||||
|
|
@ -2745,12 +2754,6 @@ 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"
|
||||
|
|
@ -4020,6 +4023,17 @@ version = "1.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lean_string"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "962df00ba70ac8d5ca5c064e17e5c3d090c087fd8d21aa45096c716b169da514"
|
||||
dependencies = [
|
||||
"castaway",
|
||||
"itoa",
|
||||
"ryu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
|
|
@ -4309,9 +4323,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.18"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2"
|
||||
checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
|
|
@ -4844,9 +4858,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.2.1"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
|
|
@ -5751,12 +5765,12 @@ checksum = "4904c83c6e51f1b9b08bfa5a86f35a51798e8307186e6f5513852210a219c0bb"
|
|||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "3.7.0"
|
||||
version = "2.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
|
||||
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
||||
dependencies = [
|
||||
"bitflags 2.11.0",
|
||||
"core-foundation 0.10.1",
|
||||
"core-foundation 0.9.4",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"security-framework-sys",
|
||||
|
|
@ -6056,9 +6070,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "503ac8c991a76998d4ba699ef9b7f0085d3d7c363d1fcce4219314f909746bca"
|
||||
checksum = "ffb9556aaf74b2bff490660cdb9681a45f84c648aa745a11d61ef38ee4245048"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytemuck",
|
||||
|
|
@ -6079,9 +6093,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-bindings-macro"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1214628a7c29ee58255d511b7c4dbaaa463bc5022dba9401f264c1c85b5a891c"
|
||||
checksum = "fea86ac365c991dff6f468bf23d4dbec88ba3737fe07285a35ff047363cf4d16"
|
||||
dependencies = [
|
||||
"heck 0.4.1",
|
||||
"humantime",
|
||||
|
|
@ -6093,18 +6107,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-bindings-sys"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4777d90692bade6601887a21a074b71c157b34a92a5cfc8d5ecb46a0c571094"
|
||||
checksum = "81c8920e17bc35bbdbe5195974df2f4778f9954907ec6d726693c8bc7b8f105c"
|
||||
dependencies = [
|
||||
"spacetimedb-primitives",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spacetimedb-client-api-messages"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "745d7ab0f81e3f6333d3ee353ce314b73841fbfe06adad69ab43efa791301da3"
|
||||
checksum = "b4e7c961c8180dfd02f1371aec33ff4d413788ed084810e2f3ef26be005e0f52"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"bytestring",
|
||||
|
|
@ -6124,9 +6138,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-data-structures"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5d85162537b1eeb6eac39383e34ca27aafcbf26987753172ca3de1de1e3a838"
|
||||
checksum = "46af9a2830f4eeb1fd9cd3f43458a5acedc4e749317438a961299633514af47e"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"crossbeam-queue",
|
||||
|
|
@ -6139,9 +6153,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-lib"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c5e91c66b10dc38cce01928d3f77313276e34c635504e54afdec6f186a2fc9c"
|
||||
checksum = "580db5e0e718f52e98134e465088cc29d5f0fc2c8da3c812f0eb303d289bec5f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.11.0",
|
||||
|
|
@ -6163,9 +6177,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-memory-usage"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9c081d3ffafa9c2fa11194b4ea3329773d979e342944b0128282bcbf5d3343"
|
||||
checksum = "0e6c3b3d6c002409a49660314ff359fc84b4ee7fdd3f868ee1cf6adf5bcbe2d4"
|
||||
dependencies = [
|
||||
"decorum",
|
||||
"ethnum",
|
||||
|
|
@ -6173,9 +6187,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-metrics"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985858969f693529c8624ce195cb747a34f7c84f3097418f595f795c0559fbd1"
|
||||
checksum = "00d469629100b1bd9d5a6ea2ab5c5f4aff8f63f631f20d39968cca909d5bad3c"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"itertools 0.12.1",
|
||||
|
|
@ -6185,9 +6199,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-primitives"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f0321a161fa39f0937aceb436b47115cd811212799ddaf7996a8ecac3476d8d"
|
||||
checksum = "b4adc6d5be578f5cf51179fc2ff26ba57125390610cc1ded51db417955ef4e4c"
|
||||
dependencies = [
|
||||
"bitflags 2.11.0",
|
||||
"either",
|
||||
|
|
@ -6199,18 +6213,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-query-builder"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9df8137b6dc2739d4efbc6218c5fb106f1e105a1345819a74053b677bd38c429"
|
||||
checksum = "5d58043175057a72b22be6258d375d17f8bd9d344bc4d9a5f6d16c1244bb0769"
|
||||
dependencies = [
|
||||
"spacetimedb-lib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spacetimedb-sats"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4e07b1bc933156b0cbe6b6c759e57381ce95df52c4522d9c3d71df59c01cf20"
|
||||
checksum = "e9d1353d105fac30eb3b5f6a997a9028ad4e7cd7b6bcb48bca8c77687c17e556"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
|
|
@ -6225,6 +6239,7 @@ dependencies = [
|
|||
"ethnum",
|
||||
"hex",
|
||||
"itertools 0.12.1",
|
||||
"lean_string",
|
||||
"rand 0.9.2",
|
||||
"second-stack",
|
||||
"serde",
|
||||
|
|
@ -6240,19 +6255,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-schema"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2763b4769028f111032f00b35635f6cbb0562f54a59d05775f5ea66d7b8f8d2"
|
||||
checksum = "6f72983323b38e3966c70cf57c50ac0fbf54b6648f65f7ef1a02a2456c5725af"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"convert_case 0.6.0",
|
||||
"derive_more 0.99.20",
|
||||
"ecow",
|
||||
"enum-as-inner",
|
||||
"enum-map",
|
||||
"indexmap 2.13.0",
|
||||
"insta",
|
||||
"itertools 0.12.1",
|
||||
"lazy_static",
|
||||
"lean_string",
|
||||
"petgraph 0.6.5",
|
||||
"serde_json",
|
||||
"smallvec",
|
||||
|
|
@ -6270,9 +6286,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-sdk"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "243f7b433aa0ba1d665aeb9db397b9bd40698d80817840d8fa8d8bfe74e99f00"
|
||||
checksum = "e8dd5a40d5aa7893ed1c71d73b7103b0326d1e4294c3c63fbd82a05754e15eae"
|
||||
dependencies = [
|
||||
"anymap",
|
||||
"base64 0.21.7",
|
||||
|
|
@ -6284,6 +6300,7 @@ dependencies = [
|
|||
"home",
|
||||
"http",
|
||||
"log",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"prometheus",
|
||||
"rand 0.9.2",
|
||||
|
|
@ -6301,9 +6318,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "spacetimedb-sql-parser"
|
||||
version = "1.12.0"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98cd63f69d4d6b074771830d8f8d12ce52c253179940c1bd02a50adeba7a9485"
|
||||
checksum = "7ddf20b921097b6233ab3205101833ed8a1b795358ae3feaa81a5c29cc452aea"
|
||||
dependencies = [
|
||||
"derive_more 0.99.20",
|
||||
"spacetimedb-lib",
|
||||
|
|
|
|||
|
|
@ -12,10 +12,9 @@ bevy.default-features = false
|
|||
bevy_ratatui = "0.11.1"
|
||||
bevy_spacetimedb = "0.7"
|
||||
|
||||
spacetimedb.version = "1.12.*"
|
||||
spacetimedb.version = "2.0.1"
|
||||
spacetimedb.features = ["unstable"]
|
||||
|
||||
spacetimedb-sdk = "1.12.*"
|
||||
spacetimedb-sdk = "2.0.1"
|
||||
|
||||
strum.version = "0.27.2"
|
||||
strum.features = ["derive"]
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ impl __sdk::InModule for AddBotArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct AddBotCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `add_bot`.
|
||||
///
|
||||
|
|
@ -33,72 +31,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`add_bot:add_bot_then`] to run a callback after the reducer completes.
|
||||
fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()> {
|
||||
self.add_bot_then(lobby_id, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `add_bot` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn add_bot_then(
|
||||
&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);
|
||||
lobby_id: u32,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
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 on_add_bot(
|
||||
fn add_bot_then(
|
||||
&self,
|
||||
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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, lobby_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_add_bot(&self, callback: AddBotCallbackId) {
|
||||
self.imp.remove_on_reducer("add_bot", callback.0)
|
||||
}
|
||||
}
|
||||
lobby_id: u32,
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `add_bot`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_add_bot {
|
||||
/// Set the call-reducer flags for the reducer `add_bot` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn add_bot(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_add_bot for super::SetReducerFlags {
|
||||
fn add_bot(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("add_bot", flags);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AddBotArgs { lobby_id }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ 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`.
|
||||
///
|
||||
|
|
@ -35,73 +33,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`advance_game:advance_game_then`] to run a callback after the reducer completes.
|
||||
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> {
|
||||
self.advance_game_then(game_timer, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `advance_game` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// 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(
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed with the `callback`.
|
||||
fn advance_game_then(
|
||||
&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);
|
||||
game_timer: GameTimer,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
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(
|
||||
fn advance_game_then(
|
||||
&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)
|
||||
}
|
||||
}
|
||||
game_timer: GameTimer,
|
||||
|
||||
#[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);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AdvanceGameArgs { game_timer }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,6 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Bot>("bot");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct BotUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BotTableHandle<'ctx> {
|
||||
|
|
@ -102,17 +97,6 @@ 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<Bot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Bot>", "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.
|
||||
|
|
@ -143,6 +127,23 @@ impl<'ctx> BotIdUnique<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Bot>("bot");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<Bot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Bot>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `Bot`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -65,3 +65,5 @@ impl __sdk::__query_builder::HasIxCols for Bot {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for Bot {}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ impl __sdk::InModule for ClearAllArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct ClearAllCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `clear_all`.
|
||||
///
|
||||
|
|
@ -29,72 +27,36 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `clear_all`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`clear_all:clear_all_then`] to run a callback after the reducer completes.
|
||||
fn clear_all(&self) -> __sdk::Result<()> {
|
||||
self.clear_all_then(|_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `clear_all` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`ClearAllCallbackId`] can be passed to [`Self::remove_on_clear_all`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn clear_all_then(
|
||||
&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);
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
impl clear_all for super::RemoteReducers {
|
||||
fn clear_all(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("clear_all", ClearAllArgs {})
|
||||
}
|
||||
fn on_clear_all(
|
||||
fn clear_all_then(
|
||||
&self,
|
||||
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 {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_clear_all(&self, callback: ClearAllCallbackId) {
|
||||
self.imp.remove_on_reducer("clear_all", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `clear_all`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_clear_all {
|
||||
/// Set the call-reducer flags for the reducer `clear_all` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn clear_all(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_clear_all for super::SetReducerFlags {
|
||||
fn clear_all(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("clear_all", flags);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(ClearAllArgs {}, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ConnectArgs {}
|
||||
|
||||
impl From<ConnectArgs> 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,3 +50,5 @@ impl __sdk::__query_builder::HasIxCols for DbTile {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for DbTile {}
|
||||
|
|
|
|||
|
|
@ -50,3 +50,5 @@ impl __sdk::__query_builder::HasIxCols for DbWall {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for DbWall {}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ impl __sdk::InModule for DiscardTileArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct DiscardTileCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `discard_tile`.
|
||||
///
|
||||
|
|
@ -33,73 +31,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `discard_tile`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`discard_tile:discard_tile_then`] to run a callback after the reducer completes.
|
||||
fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()> {
|
||||
self.discard_tile_then(tile_id, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `discard_tile` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`DiscardTileCallbackId`] can be passed to [`Self::remove_on_discard_tile`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn discard_tile_then(
|
||||
&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);
|
||||
tile_id: u32,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
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 on_discard_tile(
|
||||
fn discard_tile_then(
|
||||
&self,
|
||||
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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, tile_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId) {
|
||||
self.imp.remove_on_reducer("discard_tile", callback.0)
|
||||
}
|
||||
}
|
||||
tile_id: u32,
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `discard_tile`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_discard_tile {
|
||||
/// Set the call-reducer flags for the reducer `discard_tile` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn discard_tile(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_discard_tile for super::SetReducerFlags {
|
||||
fn discard_tile(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("discard_tile", flags);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(DiscardTileArgs { tile_id }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 DisconnectArgs {}
|
||||
|
||||
impl From<DisconnectArgs> 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -78,12 +78,6 @@ impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<GameTimer>("game_timer");
|
||||
_table.add_unique_constraint::<u64>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
|
||||
}
|
||||
pub struct GameTimerUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> {
|
||||
|
|
@ -101,17 +95,6 @@ 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<GameTimer>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<GameTimer>", "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.
|
||||
|
|
@ -172,6 +155,24 @@ impl<'ctx> GameTimerLobbyIdUnique<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<GameTimer>("game_timer");
|
||||
_table.add_unique_constraint::<u64>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<GameTimer>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<GameTimer>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `GameTimer`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -53,3 +53,5 @@ impl __sdk::__query_builder::HasIxCols for GameTimer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for GameTimer {}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ impl __sdk::InModule for JoinOrCreateLobbyArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct JoinOrCreateLobbyCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `join_or_create_lobby`.
|
||||
///
|
||||
|
|
@ -33,75 +31,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`join_or_create_lobby:join_or_create_lobby_then`] to run a callback after the reducer completes.
|
||||
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> {
|
||||
self.join_or_create_lobby_then(lobby_id, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `join_or_create_lobby` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`JoinOrCreateLobbyCallbackId`] can be passed to [`Self::remove_on_join_or_create_lobby`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn join_or_create_lobby_then(
|
||||
&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);
|
||||
lobby_id: u32,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
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 on_join_or_create_lobby(
|
||||
fn join_or_create_lobby_then(
|
||||
&self,
|
||||
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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = 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)
|
||||
}
|
||||
}
|
||||
lobby_id: u32,
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `join_or_create_lobby`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_join_or_create_lobby {
|
||||
/// Set the call-reducer flags for the reducer `join_or_create_lobby` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_join_or_create_lobby for super::SetReducerFlags {
|
||||
fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags) {
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.set_call_reducer_flags("join_or_create_lobby", flags);
|
||||
.invoke_reducer_with_callback(JoinOrCreateLobbyArgs { lobby_id }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,6 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct LobbyUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> {
|
||||
|
|
@ -102,17 +97,6 @@ impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<Lobby>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Lobby>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
|
@ -143,6 +127,23 @@ impl<'ctx> LobbyIdUnique<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<Lobby>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Lobby>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `Lobby`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -60,3 +60,5 @@ impl __sdk::__query_builder::HasIxCols for Lobby {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for Lobby {}
|
||||
|
|
|
|||
|
|
@ -1,191 +0,0 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::player_type::Player;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `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<Player>,
|
||||
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::<Player>("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<Item = Player> + '_ {
|
||||
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<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Player>("logged_out_player");
|
||||
_table.add_unique_constraint::<u32>("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<Player>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Player>", "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<Player, u32>,
|
||||
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::<u32>("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<Player> {
|
||||
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<Player, __sdk::Identity>,
|
||||
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<Player> {
|
||||
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<Player>;
|
||||
}
|
||||
|
||||
impl logged_out_playerQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn logged_out_player(&self) -> __sdk::__query_builder::Table<Player> {
|
||||
__sdk::__query_builder::Table::new("logged_out_player")
|
||||
}
|
||||
}
|
||||
|
|
@ -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.12.0 (commit 4fdb8d923f39ed592931ad4c7e6391ed99b9fe3a).
|
||||
// This was generated using spacetimedb cli version 2.0.1 (commit a4d29daec8ed35ce4913a335b7210b9ae3933d00).
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
|
@ -11,11 +11,9 @@ 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 dragon_type;
|
||||
pub mod game_state_type;
|
||||
pub mod game_timer_table;
|
||||
|
|
@ -24,10 +22,8 @@ pub mod hand_view_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_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;
|
||||
|
|
@ -35,51 +31,41 @@ 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 view_closed_hands_table;
|
||||
pub mod view_hand_table;
|
||||
pub mod wall_table;
|
||||
pub mod wind_type;
|
||||
|
||||
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 add_bot_reducer::add_bot;
|
||||
pub use advance_game_reducer::advance_game;
|
||||
pub use bot_table::*;
|
||||
pub use bot_type::Bot;
|
||||
pub use clear_all_reducer::{clear_all, set_flags_for_clear_all, ClearAllCallbackId};
|
||||
pub use connect_reducer::{connect, set_flags_for_connect, ConnectCallbackId};
|
||||
pub use clear_all_reducer::clear_all;
|
||||
pub use db_tile_type::DbTile;
|
||||
pub use db_wall_type::DbWall;
|
||||
pub use discard_tile_reducer::{discard_tile, set_flags_for_discard_tile, DiscardTileCallbackId};
|
||||
pub use disconnect_reducer::{disconnect, set_flags_for_disconnect, DisconnectCallbackId};
|
||||
pub use discard_tile_reducer::discard_tile;
|
||||
pub use dragon_type::Dragon;
|
||||
pub use game_state_type::GameState;
|
||||
pub use game_timer_table::*;
|
||||
pub use game_timer_type::GameTimer;
|
||||
pub use hand_view_type::HandView;
|
||||
pub use join_or_create_lobby_reducer::{
|
||||
join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId,
|
||||
};
|
||||
pub use join_or_create_lobby_reducer::join_or_create_lobby;
|
||||
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 set_ready_reducer::set_ready;
|
||||
pub use suit_type::Suit;
|
||||
pub use tile_table::*;
|
||||
pub use tile_type::Tile;
|
||||
pub use turn_state_type::TurnState;
|
||||
pub use view_closed_hands_table::*;
|
||||
pub use view_hand_table::*;
|
||||
pub use wall_table::*;
|
||||
pub use wind_type::Wind;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
|
|
@ -93,9 +79,7 @@ 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 },
|
||||
}
|
||||
|
|
@ -110,74 +94,40 @@ impl __sdk::Reducer for Reducer {
|
|||
Reducer::AddBot { .. } => "add_bot",
|
||||
Reducer::AdvanceGame { .. } => "advance_game",
|
||||
Reducer::ClearAll => "clear_all",
|
||||
Reducer::Connect => "connect",
|
||||
Reducer::DiscardTile { .. } => "discard_tile",
|
||||
Reducer::Disconnect => "disconnect",
|
||||
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<Self> {
|
||||
match &value.reducer_name[..] {
|
||||
"add_bot" => Ok(__sdk::parse_reducer_args::<add_bot_reducer::AddBotArgs>(
|
||||
"add_bot",
|
||||
&value.args,
|
||||
)?
|
||||
.into()),
|
||||
"advance_game" => Ok(
|
||||
__sdk::parse_reducer_args::<advance_game_reducer::AdvanceGameArgs>(
|
||||
"advance_game",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"clear_all" => Ok(
|
||||
__sdk::parse_reducer_args::<clear_all_reducer::ClearAllArgs>(
|
||||
"clear_all",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"connect" => Ok(__sdk::parse_reducer_args::<connect_reducer::ConnectArgs>(
|
||||
"connect",
|
||||
&value.args,
|
||||
)?
|
||||
.into()),
|
||||
"discard_tile" => Ok(
|
||||
__sdk::parse_reducer_args::<discard_tile_reducer::DiscardTileArgs>(
|
||||
"discard_tile",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"disconnect" => Ok(
|
||||
__sdk::parse_reducer_args::<disconnect_reducer::DisconnectArgs>(
|
||||
"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_reducer::SetReadyArgs>(
|
||||
"set_ready",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
unknown => {
|
||||
Err(
|
||||
__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo")
|
||||
.into(),
|
||||
)
|
||||
#[allow(clippy::clone_on_copy)]
|
||||
fn args_bsatn(&self) -> Result<Vec<u8>, __sats::bsatn::EncodeError> {
|
||||
match self {
|
||||
Reducer::AddBot { lobby_id } => __sats::bsatn::to_vec(&add_bot_reducer::AddBotArgs {
|
||||
lobby_id: lobby_id.clone(),
|
||||
}),
|
||||
Reducer::AdvanceGame { game_timer } => {
|
||||
__sats::bsatn::to_vec(&advance_game_reducer::AdvanceGameArgs {
|
||||
game_timer: game_timer.clone(),
|
||||
})
|
||||
}
|
||||
Reducer::ClearAll => __sats::bsatn::to_vec(&clear_all_reducer::ClearAllArgs {}),
|
||||
Reducer::DiscardTile { tile_id } => {
|
||||
__sats::bsatn::to_vec(&discard_tile_reducer::DiscardTileArgs {
|
||||
tile_id: tile_id.clone(),
|
||||
})
|
||||
}
|
||||
Reducer::JoinOrCreateLobby { lobby_id } => {
|
||||
__sats::bsatn::to_vec(&join_or_create_lobby_reducer::JoinOrCreateLobbyArgs {
|
||||
lobby_id: lobby_id.clone(),
|
||||
})
|
||||
}
|
||||
Reducer::SetReady { ready } => {
|
||||
__sats::bsatn::to_vec(&set_ready_reducer::SetReadyArgs {
|
||||
ready: ready.clone(),
|
||||
})
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,21 +139,17 @@ pub struct DbUpdate {
|
|||
bot: __sdk::TableUpdate<Bot>,
|
||||
game_timer: __sdk::TableUpdate<GameTimer>,
|
||||
lobby: __sdk::TableUpdate<Lobby>,
|
||||
logged_out_player: __sdk::TableUpdate<Player>,
|
||||
player: __sdk::TableUpdate<Player>,
|
||||
player_clock: __sdk::TableUpdate<PlayerClock>,
|
||||
player_hand: __sdk::TableUpdate<PlayerHand>,
|
||||
tile: __sdk::TableUpdate<DbTile>,
|
||||
view_closed_hands: __sdk::TableUpdate<HandView>,
|
||||
view_hand: __sdk::TableUpdate<PlayerHand>,
|
||||
wall: __sdk::TableUpdate<DbWall>,
|
||||
}
|
||||
|
||||
impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate {
|
||||
impl TryFrom<__ws::v2::TransactionUpdate> for DbUpdate {
|
||||
type Error = __sdk::Error;
|
||||
fn try_from(raw: __ws::DatabaseUpdate<__ws::BsatnFormat>) -> Result<Self, Self::Error> {
|
||||
fn try_from(raw: __ws::v2::TransactionUpdate) -> Result<Self, Self::Error> {
|
||||
let mut db_update = DbUpdate::default();
|
||||
for table_update in raw.tables {
|
||||
for table_update in __sdk::transaction_update_iter_table_updates(raw) {
|
||||
match &table_update.table_name[..] {
|
||||
"bot" => db_update
|
||||
.bot
|
||||
|
|
@ -214,30 +160,18 @@ impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate {
|
|||
"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)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(view_closed_hands_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)?),
|
||||
|
||||
unknown => {
|
||||
return Err(__sdk::InternalError::unknown_name(
|
||||
|
|
@ -273,30 +207,86 @@ impl __sdk::DbUpdate for DbUpdate {
|
|||
diff.lobby = cache
|
||||
.apply_diff_to_table::<Lobby>("lobby", &self.lobby)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.logged_out_player = cache
|
||||
.apply_diff_to_table::<Player>("logged_out_player", &self.logged_out_player)
|
||||
.with_updates_by_pk(|row| &row.identity);
|
||||
diff.player = cache
|
||||
.apply_diff_to_table::<Player>("player", &self.player)
|
||||
.with_updates_by_pk(|row| &row.identity);
|
||||
diff.player_clock = cache
|
||||
.apply_diff_to_table::<PlayerClock>("player_clock", &self.player_clock)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.player_hand = cache
|
||||
.apply_diff_to_table::<PlayerHand>("player_hand", &self.player_hand)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.tile = cache
|
||||
.apply_diff_to_table::<DbTile>("tile", &self.tile)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.wall = cache
|
||||
.apply_diff_to_table::<DbWall>("wall", &self.wall)
|
||||
.with_updates_by_pk(|row| &row.lobby_id);
|
||||
diff.view_closed_hands =
|
||||
cache.apply_diff_to_table::<HandView>("view_closed_hands", &self.view_closed_hands);
|
||||
diff.view_hand = cache.apply_diff_to_table::<PlayerHand>("view_hand", &self.view_hand);
|
||||
|
||||
diff
|
||||
}
|
||||
fn parse_initial_rows(raw: __ws::v2::QueryRows) -> __sdk::Result<Self> {
|
||||
let mut db_update = DbUpdate::default();
|
||||
for table_rows in raw.tables {
|
||||
match &table_rows.table[..] {
|
||||
"bot" => db_update
|
||||
.bot
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"game_timer" => db_update
|
||||
.game_timer
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"player" => db_update
|
||||
.player
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"player_clock" => db_update
|
||||
.player_clock
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
"view_hand" => db_update
|
||||
.view_hand
|
||||
.append(__sdk::parse_row_list_as_inserts(table_rows.rows)?),
|
||||
unknown => {
|
||||
return Err(
|
||||
__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(db_update)
|
||||
}
|
||||
fn parse_unsubscribe_rows(raw: __ws::v2::QueryRows) -> __sdk::Result<Self> {
|
||||
let mut db_update = DbUpdate::default();
|
||||
for table_rows in raw.tables {
|
||||
match &table_rows.table[..] {
|
||||
"bot" => db_update
|
||||
.bot
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"game_timer" => db_update
|
||||
.game_timer
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"player" => db_update
|
||||
.player
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"player_clock" => db_update
|
||||
.player_clock
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"view_closed_hands" => db_update
|
||||
.view_closed_hands
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
"view_hand" => db_update
|
||||
.view_hand
|
||||
.append(__sdk::parse_row_list_as_deletes(table_rows.rows)?),
|
||||
unknown => {
|
||||
return Err(
|
||||
__sdk::InternalError::unknown_name("table", unknown, "QueryRows").into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(db_update)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -306,14 +296,10 @@ pub struct AppliedDiff<'r> {
|
|||
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>,
|
||||
view_closed_hands: __sdk::TableAppliedDiff<'r, HandView>,
|
||||
view_hand: __sdk::TableAppliedDiff<'r, PlayerHand>,
|
||||
wall: __sdk::TableAppliedDiff<'r, DbWall>,
|
||||
__unused: std::marker::PhantomData<&'r ()>,
|
||||
}
|
||||
|
||||
|
|
@ -330,26 +316,18 @@ impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
|||
callbacks.invoke_table_row_callbacks::<Bot>("bot", &self.bot, event);
|
||||
callbacks.invoke_table_row_callbacks::<GameTimer>("game_timer", &self.game_timer, event);
|
||||
callbacks.invoke_table_row_callbacks::<Lobby>("lobby", &self.lobby, event);
|
||||
callbacks.invoke_table_row_callbacks::<Player>(
|
||||
"logged_out_player",
|
||||
&self.logged_out_player,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<Player>("player", &self.player, event);
|
||||
callbacks.invoke_table_row_callbacks::<PlayerClock>(
|
||||
"player_clock",
|
||||
&self.player_clock,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<PlayerHand>("player_hand", &self.player_hand, event);
|
||||
callbacks.invoke_table_row_callbacks::<DbTile>("tile", &self.tile, event);
|
||||
callbacks.invoke_table_row_callbacks::<HandView>(
|
||||
"view_closed_hands",
|
||||
&self.view_closed_hands,
|
||||
event,
|
||||
);
|
||||
callbacks.invoke_table_row_callbacks::<PlayerHand>("view_hand", &self.view_hand, event);
|
||||
callbacks.invoke_table_row_callbacks::<DbWall>("wall", &self.wall, event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -380,20 +358,6 @@ impl __sdk::InModule for RemoteProcedures {
|
|||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
/// The `set_reducer_flags` field of [`DbConnection`],
|
||||
/// with methods provided by extension traits for each reducer defined by the module.
|
||||
/// Each method sets the flags for the reducer with the same name.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub struct SetReducerFlags {
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SetReducerFlags {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
/// The `db` field of [`EventContext`] and [`DbConnection`],
|
||||
/// with methods provided by extension traits for each table defined by the module.
|
||||
pub struct RemoteTables {
|
||||
|
|
@ -426,11 +390,6 @@ pub struct DbConnection {
|
|||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
#[doc(hidden)]
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
|
|
@ -446,7 +405,6 @@ impl __sdk::DbContext for DbConnection {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -457,9 +415,6 @@ impl __sdk::DbContext for DbConnection {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -563,7 +518,6 @@ impl __sdk::DbConnection for DbConnection {
|
|||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
|
|
@ -615,7 +569,6 @@ pub trait RemoteDbContext:
|
|||
__sdk::DbContext<
|
||||
DbView = RemoteTables,
|
||||
Reducers = RemoteReducers,
|
||||
SetReducerFlags = SetReducerFlags,
|
||||
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
|
||||
>
|
||||
{
|
||||
|
|
@ -624,7 +577,6 @@ impl<
|
|||
Ctx: __sdk::DbContext<
|
||||
DbView = RemoteTables,
|
||||
Reducers = RemoteReducers,
|
||||
SetReducerFlags = SetReducerFlags,
|
||||
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
|
||||
>,
|
||||
> RemoteDbContext for Ctx
|
||||
|
|
@ -638,11 +590,6 @@ pub struct EventContext {
|
|||
pub db: RemoteTables,
|
||||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
/// The event which caused these callbacks to run.
|
||||
|
|
@ -659,7 +606,6 @@ impl __sdk::AbstractEventContext for EventContext {
|
|||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
event,
|
||||
imp,
|
||||
|
|
@ -675,7 +621,6 @@ impl __sdk::DbContext for EventContext {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -686,9 +631,6 @@ impl __sdk::DbContext for EventContext {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -724,11 +666,6 @@ pub struct ReducerEventContext {
|
|||
pub db: RemoteTables,
|
||||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
/// The event which caused these callbacks to run.
|
||||
|
|
@ -745,7 +682,6 @@ impl __sdk::AbstractEventContext for ReducerEventContext {
|
|||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
event,
|
||||
imp,
|
||||
|
|
@ -761,7 +697,6 @@ impl __sdk::DbContext for ReducerEventContext {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -772,9 +707,6 @@ impl __sdk::DbContext for ReducerEventContext {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -809,11 +741,6 @@ pub struct ProcedureEventContext {
|
|||
pub db: RemoteTables,
|
||||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
|
|
@ -829,7 +756,6 @@ impl __sdk::AbstractEventContext for ProcedureEventContext {
|
|||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
|
|
@ -843,7 +769,6 @@ impl __sdk::DbContext for ProcedureEventContext {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -854,9 +779,6 @@ impl __sdk::DbContext for ProcedureEventContext {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -891,11 +813,6 @@ pub struct SubscriptionEventContext {
|
|||
pub db: RemoteTables,
|
||||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
|
|
@ -911,7 +828,6 @@ impl __sdk::AbstractEventContext for SubscriptionEventContext {
|
|||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
|
|
@ -925,7 +841,6 @@ impl __sdk::DbContext for SubscriptionEventContext {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -936,9 +851,6 @@ impl __sdk::DbContext for SubscriptionEventContext {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -974,11 +886,6 @@ pub struct ErrorContext {
|
|||
pub db: RemoteTables,
|
||||
/// Access to reducers defined by the module via extension traits implemented for [`RemoteReducers`].
|
||||
pub reducers: RemoteReducers,
|
||||
/// Access to setting the call-flags of each reducer defined for each reducer defined by the module
|
||||
/// via extension traits implemented for [`SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub set_reducer_flags: SetReducerFlags,
|
||||
/// Access to procedures defined by the module via extension traits implemented for [`RemoteProcedures`].
|
||||
pub procedures: RemoteProcedures,
|
||||
/// The event which caused these callbacks to run.
|
||||
|
|
@ -995,7 +902,6 @@ impl __sdk::AbstractEventContext for ErrorContext {
|
|||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
event,
|
||||
imp,
|
||||
|
|
@ -1011,7 +917,6 @@ impl __sdk::DbContext for ErrorContext {
|
|||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
|
|
@ -1022,9 +927,6 @@ impl __sdk::DbContext for ErrorContext {
|
|||
fn procedures(&self) -> &Self::Procedures {
|
||||
&self.procedures
|
||||
}
|
||||
fn set_reducer_flags(&self) -> &Self::SetReducerFlags {
|
||||
&self.set_reducer_flags
|
||||
}
|
||||
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
|
|
@ -1063,7 +965,7 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
|||
type Reducer = Reducer;
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
type Procedures = RemoteProcedures;
|
||||
type DbUpdate = DbUpdate;
|
||||
type AppliedDiff<'r> = AppliedDiff<'r>;
|
||||
type SubscriptionHandle = SubscriptionHandle;
|
||||
|
|
@ -1073,13 +975,18 @@ impl __sdk::SpacetimeModule for RemoteModule {
|
|||
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);
|
||||
view_closed_hands_table::register_table(client_cache);
|
||||
view_hand_table::register_table(client_cache);
|
||||
wall_table::register_table(client_cache);
|
||||
}
|
||||
const ALL_TABLE_NAMES: &'static [&'static str] = &[
|
||||
"bot",
|
||||
"game_timer",
|
||||
"lobby",
|
||||
"player",
|
||||
"player_clock",
|
||||
"view_closed_hands",
|
||||
"view_hand",
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,12 +78,6 @@ impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<PlayerClock>("player_clock");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<u32>("player_id", |row| &row.player_id);
|
||||
}
|
||||
pub struct PlayerClockUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for PlayerClockTableHandle<'ctx> {
|
||||
|
|
@ -101,17 +95,6 @@ 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<PlayerClock>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<PlayerClock>", "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.
|
||||
|
|
@ -172,6 +155,24 @@ impl<'ctx> PlayerClockPlayerIdUnique<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<PlayerClock>("player_clock");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<u32>("player_id", |row| &row.player_id);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<PlayerClock>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<PlayerClock>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `PlayerClock`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -56,3 +56,5 @@ impl __sdk::__query_builder::HasIxCols for PlayerClock {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for PlayerClock {}
|
||||
|
|
|
|||
|
|
@ -1,191 +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::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 `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<PlayerHand>,
|
||||
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::<PlayerHand>("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<Item = PlayerHand> + '_ {
|
||||
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<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<PlayerHand>("player_hand");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<u32>("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<PlayerHand>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<PlayerHand>", "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<PlayerHand, u32>,
|
||||
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::<u32>("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<PlayerHand> {
|
||||
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<PlayerHand, u32>,
|
||||
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::<u32>("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<PlayerHand> {
|
||||
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<PlayerHand>;
|
||||
}
|
||||
|
||||
impl player_handQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn player_hand(&self) -> __sdk::__query_builder::Table<PlayerHand> {
|
||||
__sdk::__query_builder::Table::new("player_hand")
|
||||
}
|
||||
}
|
||||
|
|
@ -65,3 +65,5 @@ impl __sdk::__query_builder::HasIxCols for PlayerHand {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for PlayerHand {}
|
||||
|
|
|
|||
|
|
@ -78,12 +78,6 @@ impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Player>("player");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
|
||||
}
|
||||
pub struct PlayerUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> {
|
||||
|
|
@ -101,17 +95,6 @@ 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<Player>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Player>", "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.
|
||||
|
|
@ -174,6 +157,24 @@ impl<'ctx> PlayerIdentityUnique<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Player>("player");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<Player>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Player>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for query builder access to the table `Player`.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -64,3 +64,5 @@ impl __sdk::__query_builder::HasIxCols for Player {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::__query_builder::CanBeLookupTable for Player {}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ impl __sdk::InModule for SetReadyArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct SetReadyCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `set_ready`.
|
||||
///
|
||||
|
|
@ -31,72 +29,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`set_ready:set_ready_then`] to run a callback after the reducer completes.
|
||||
fn set_ready(&self, ready: bool) -> __sdk::Result<()> {
|
||||
self.set_ready_then(ready, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `set_ready` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn set_ready_then(
|
||||
&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);
|
||||
ready: bool,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
impl set_ready for super::RemoteReducers {
|
||||
fn set_ready(&self, ready: bool) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("set_ready", SetReadyArgs { ready })
|
||||
}
|
||||
fn on_set_ready(
|
||||
fn set_ready_then(
|
||||
&self,
|
||||
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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, ready)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_set_ready(&self, callback: SetReadyCallbackId) {
|
||||
self.imp.remove_on_reducer("set_ready", callback.0)
|
||||
}
|
||||
}
|
||||
ready: bool,
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `set_ready`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_set_ready {
|
||||
/// Set the call-reducer flags for the reducer `set_ready` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn set_ready(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_set_ready for super::SetReducerFlags {
|
||||
fn set_ready(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("set_ready", flags);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(SetReadyArgs { ready }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,159 +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::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`.
|
||||
///
|
||||
/// Obtain a handle from the [`TileTableAccess::tile`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.tile()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.tile().on_insert(...)`.
|
||||
pub struct TileTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<DbTile>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `tile`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait TileTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`TileTableHandle`], which mediates access to the table `tile`.
|
||||
fn tile(&self) -> TileTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl TileTableAccess for super::RemoteTables {
|
||||
fn tile(&self) -> TileTableHandle<'_> {
|
||||
TileTableHandle {
|
||||
imp: self.imp.get_table::<DbTile>("tile"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TileInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct TileDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
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<Item = DbTile> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = TileInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> TileInsertCallbackId {
|
||||
TileInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: TileInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = TileDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> TileDeleteCallbackId {
|
||||
TileDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: TileDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<DbTile>("tile");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct TileUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for TileTableHandle<'ctx> {
|
||||
type UpdateCallbackId = TileUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> TileUpdateCallbackId {
|
||||
TileUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: TileUpdateCallbackId) {
|
||||
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<DbTile>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<DbTile>", "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<DbTile, u32>,
|
||||
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::<u32>("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<DbTile> {
|
||||
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<DbTile>;
|
||||
}
|
||||
|
||||
impl tileQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn tile(&self) -> __sdk::__query_builder::Table<DbTile> {
|
||||
__sdk::__query_builder::Table::new("tile")
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::Remote
|
|||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<HandView>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<HandView>", "TableUpdate")
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::Remote
|
|||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
raw_updates: __ws::v2::TableUpdate,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<PlayerHand>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<PlayerHand>", "TableUpdate")
|
||||
|
|
|
|||
|
|
@ -1,159 +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::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`.
|
||||
///
|
||||
/// 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<DbWall>,
|
||||
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::<DbWall>("wall"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WallInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct WallDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
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<Item = DbWall> + '_ {
|
||||
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<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<DbWall>("wall");
|
||||
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
|
||||
}
|
||||
pub struct WallUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for WallTableHandle<'ctx> {
|
||||
type UpdateCallbackId = WallUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> WallUpdateCallbackId {
|
||||
WallUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: WallUpdateCallbackId) {
|
||||
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<DbWall>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<DbWall>", "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<DbWall, u32>,
|
||||
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::<u32>("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<DbWall> {
|
||||
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<DbWall>;
|
||||
}
|
||||
|
||||
impl wallQueryTableAccess for __sdk::QueryTableAccessor {
|
||||
fn wall(&self) -> __sdk::__query_builder::Table<DbWall> {
|
||||
__sdk::__query_builder::Table::new("wall")
|
||||
}
|
||||
}
|
||||
|
|
@ -29,14 +29,14 @@ pub fn clear_all(ctx: &ReducerContext) {
|
|||
|
||||
#[reducer(client_connected)]
|
||||
pub fn connect(ctx: &ReducerContext) -> Result<(), String> {
|
||||
let player = if let Some(player) = ctx.db.logged_out_player().identity().find(ctx.sender) {
|
||||
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);
|
||||
ctx.db.logged_out_player().identity().delete(ctx.sender());
|
||||
player
|
||||
} else {
|
||||
debug!("inserting new player with identity {:?}", ctx.sender);
|
||||
debug!("inserting new player with identity {:?}", ctx.sender());
|
||||
ctx.db.player().try_insert(Player {
|
||||
identity: ctx.sender,
|
||||
identity: ctx.sender(),
|
||||
id: 0,
|
||||
name: None,
|
||||
lobby_id: 0,
|
||||
|
|
@ -56,11 +56,11 @@ pub fn disconnect(ctx: &ReducerContext) -> Result<(), String> {
|
|||
.db
|
||||
.player()
|
||||
.identity()
|
||||
.find(ctx.sender)
|
||||
.ok_or_else(|| format!("can't find player {} to disconnect", ctx.sender))?;
|
||||
.find(ctx.sender())
|
||||
.ok_or_else(|| format!("can't find player {} to disconnect", ctx.sender()))?;
|
||||
|
||||
let player = ctx.db.logged_out_player().insert(player);
|
||||
if !ctx.db.player().identity().delete(ctx.sender) {
|
||||
if !ctx.db.player().identity().delete(ctx.sender()) {
|
||||
Err("can't delete row")?
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ pub fn disconnect(ctx: &ReducerContext) -> Result<(), String> {
|
|||
// if name.is_empty() {
|
||||
// return Err("names must not be empty".into());
|
||||
// }
|
||||
// if let Some(player) = ctx.db.player().identity().find(ctx.sender) {
|
||||
// if let Some(player) = ctx.db.player().identity().find(ctx.sender()) {
|
||||
// ctx.db.player().identity().update(Player {
|
||||
// name: Some(name),
|
||||
// ..player
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@ mod lobby;
|
|||
|
||||
#[reducer]
|
||||
pub fn advance_game(ctx: &ReducerContext, mut game_timer: GameTimer) -> Result<(), String> {
|
||||
advance_game_private(ctx, game_timer)
|
||||
}
|
||||
|
||||
#[reducer]
|
||||
pub fn advance_game_private(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) {
|
||||
trace!("running schedule for lobby {}", lobby.id);
|
||||
match lobby.game_state {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ 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 player = ctx.db.player().identity().find(ctx.sender).unwrap();
|
||||
let player = ctx.db.player().identity().find(ctx.sender()).unwrap();
|
||||
let mut hand = ctx.db.player_hand().player_id().find(player.id).unwrap();
|
||||
|
||||
// TODO we can probably remove a buncha these errors
|
||||
|
|
@ -51,7 +51,7 @@ pub fn discard_tile(ctx: &ReducerContext, tile_id: u32) -> Result<(), String> {
|
|||
|
||||
let mut clock = ctx.db.player_clock().player_id().find(player.id).unwrap();
|
||||
clock.renew();
|
||||
ctx.db.player_clock().player_id().update(clock);
|
||||
ctx.db.player_clock().id().update(clock);
|
||||
|
||||
let mut lobby = ctx.db.lobby().id().find(player.lobby_id).unwrap();
|
||||
lobby.next_player();
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<(
|
|||
.db
|
||||
.player()
|
||||
.identity()
|
||||
.find(ctx.sender)
|
||||
.ok_or(format!("cannot find player {}", ctx.sender))?;
|
||||
.find(ctx.sender())
|
||||
.ok_or(format!("cannot find player {}", ctx.sender()))?;
|
||||
|
||||
if lobby_id == 0 && player.lobby_id == 0 {
|
||||
// TODO check first if player is already in a lobby
|
||||
|
|
@ -74,7 +74,7 @@ pub fn add_bot(ctx: &ReducerContext, lobby_id: u32) -> Result<(), String> {
|
|||
|
||||
#[reducer]
|
||||
pub fn set_ready(ctx: &ReducerContext, ready: bool) -> Result<(), String> {
|
||||
let mut player = ctx.db.player().identity().find(ctx.sender).unwrap();
|
||||
let mut player = ctx.db.player().identity().find(ctx.sender()).unwrap();
|
||||
player.ready = ready;
|
||||
player = ctx.db.player().identity().update(player);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ use jong_types::{
|
|||
tiles::Tile,
|
||||
};
|
||||
|
||||
use crate::reducers::advance_game;
|
||||
use crate::reducers::advance_game_private;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[table(name = lobby, public)]
|
||||
#[table(accessor = lobby, public)]
|
||||
pub struct Lobby {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
|
|
@ -23,7 +23,7 @@ pub struct Lobby {
|
|||
// pub open_hands: bool,
|
||||
}
|
||||
|
||||
#[table(name = wall)]
|
||||
#[table(accessor = wall)]
|
||||
pub struct DbWall {
|
||||
#[primary_key]
|
||||
pub lobby_id: u32,
|
||||
|
|
@ -31,7 +31,7 @@ pub struct DbWall {
|
|||
pub tiles: Vec<DbTile>,
|
||||
}
|
||||
|
||||
#[table(name = tile)]
|
||||
#[table(accessor = tile)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct DbTile {
|
||||
#[primary_key]
|
||||
|
|
@ -41,8 +41,8 @@ pub struct DbTile {
|
|||
pub tile: Tile,
|
||||
}
|
||||
|
||||
#[table(name = player, public)]
|
||||
#[table(name = logged_out_player)]
|
||||
#[table(accessor = player, public)]
|
||||
#[table(accessor = logged_out_player)]
|
||||
#[derive(Debug)]
|
||||
pub struct Player {
|
||||
#[unique]
|
||||
|
|
@ -61,7 +61,7 @@ pub struct Player {
|
|||
pub sort: bool,
|
||||
}
|
||||
|
||||
#[table(name = player_clock, public)]
|
||||
#[table(accessor = player_clock, public)]
|
||||
pub struct PlayerClock {
|
||||
#[primary_key]
|
||||
pub id: u32,
|
||||
|
|
@ -73,7 +73,7 @@ pub struct PlayerClock {
|
|||
pub total: u16,
|
||||
}
|
||||
|
||||
#[table(name = player_hand)]
|
||||
#[table(accessor = player_hand)]
|
||||
pub struct PlayerHand {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
|
|
@ -91,7 +91,7 @@ pub struct PlayerHand {
|
|||
pub working_tile: Option<DbTile>,
|
||||
}
|
||||
|
||||
#[table(name = bot, public)]
|
||||
#[table(accessor = bot, public)]
|
||||
pub struct Bot {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
|
|
@ -108,7 +108,7 @@ pub struct Bot {
|
|||
pub working_tile: Option<DbTile>,
|
||||
}
|
||||
|
||||
#[table(name = game_timer, scheduled(advance_game), public)]
|
||||
#[table(accessor = game_timer, scheduled(advance_game_private), public)]
|
||||
pub struct GameTimer {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
|
|
@ -120,12 +120,12 @@ pub struct GameTimer {
|
|||
pub scheduled_at: spacetimedb::ScheduleAt,
|
||||
}
|
||||
|
||||
#[view(name = view_hand, public)]
|
||||
#[view(accessor = view_hand, public)]
|
||||
fn view_hand(ctx: &ViewContext) -> Option<PlayerHand> {
|
||||
ctx.db
|
||||
.player()
|
||||
.identity()
|
||||
.find(ctx.sender)
|
||||
.find(ctx.sender())
|
||||
.and_then(|p| ctx.db.player_hand().player_id().find(p.id))
|
||||
}
|
||||
|
||||
|
|
@ -137,9 +137,9 @@ pub struct HandView {
|
|||
pub drawn: bool,
|
||||
}
|
||||
|
||||
#[view(name = view_closed_hands, public)]
|
||||
#[view(accessor = view_closed_hands, public)]
|
||||
fn view_closed_hands(ctx: &ViewContext) -> Vec<HandView> {
|
||||
let this_player = ctx.db.player().identity().find(ctx.sender).unwrap();
|
||||
let this_player = ctx.db.player().identity().find(ctx.sender()).unwrap();
|
||||
if let Some(lobby) = ctx.db.lobby().id().find(this_player.lobby_id) {
|
||||
lobby
|
||||
.players
|
||||
|
|
|
|||
4
justfile
4
justfile
|
|
@ -18,10 +18,10 @@ spacetime:
|
|||
devenv up
|
||||
|
||||
spacetime_dev:
|
||||
spacetime dev --module-project-path jong-line --module-bindings-path jong-db/src/db jong-line --delete-data=always
|
||||
spacetime dev --module-bindings-path jong-db/src/db jong-line --delete-data=always --yes --server-only
|
||||
|
||||
spacetime_generate-bindings:
|
||||
spacetime generate --lang rust --out-dir jong-db/src/db --project-path jong-line
|
||||
spacetime generate --lang rust --out-dir jong-db/src/db --module-path jong-line
|
||||
|
||||
spacetime_restart_dev:
|
||||
mprocs -s localhost:4050 --ctl $"({c: restart-proc, name: spacetimedb_dev} | to yaml)"
|
||||
|
|
|
|||
9
spacetime.json
Normal file
9
spacetime.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"dev": {
|
||||
"run": ""
|
||||
},
|
||||
"_source-config": "spacetime.local.json",
|
||||
"module-path": "jong-line",
|
||||
"server": "local",
|
||||
"database": "jong-line"
|
||||
}
|
||||
3
spacetime.local.json
Normal file
3
spacetime.local.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"database": "jong-line"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue