integrate
This commit is contained in:
parent
004aafd4ba
commit
655123b055
37 changed files with 765 additions and 1385 deletions
|
|
@ -10,23 +10,21 @@ readme = false
|
|||
[lib]
|
||||
|
||||
[dependencies]
|
||||
# bevy_ratatui = { git = "https://github.com/kenianbei/bevy_ratatui.git", rev = "e4b022308e08ab360ef89eca8e9f8b1c969e9a56" }
|
||||
# bevy_ratatui = { path = "/home/tao/clones/bevy_ratatui" }
|
||||
bevy.features = ["dynamic_linking"]
|
||||
bevy.version = "0.17.3"
|
||||
bevy_ratatui = "0.10.0"
|
||||
bevy_spacetimedb = "0.7"
|
||||
jong-types.workspace = true
|
||||
|
||||
bevy = { workspace = true, features = ["default", "dynamic_linking"] }
|
||||
bevy_ratatui.workspace = true
|
||||
bevy_spacetimedb.workspace = true
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
jong-types = { version = "0.1.0", path = "../jong-types" }
|
||||
log = { workspace = true, features = [
|
||||
"release_max_level_error",
|
||||
"max_level_trace",
|
||||
] }
|
||||
rand = { workspace = true }
|
||||
ratatui = "0.30.0"
|
||||
rand.workspace = true
|
||||
ratatui.workspace = true
|
||||
spacetimedb-sdk.workspace = true
|
||||
spacetimedb.workspace = true
|
||||
strum = { workspace = true, features = ["derive"] }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
tui-logger.features = ["tracing-support", "crossterm"]
|
||||
tui-logger.version = "0.18.0"
|
||||
strum.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
tui-logger = { workspace = true, features = ["tracing-support", "crossterm"] }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_spacetimedb::StdbPlugin;
|
||||
|
||||
use crate::{
|
||||
game::{
|
||||
|
|
@ -7,6 +8,7 @@ use crate::{
|
|||
round::{TurnState, Wind},
|
||||
wall::Wall,
|
||||
},
|
||||
stdb::DbConnection,
|
||||
tile::{self},
|
||||
};
|
||||
|
||||
|
|
@ -43,6 +45,12 @@ impl GameMessage {
|
|||
pub struct Riichi;
|
||||
impl Plugin for Riichi {
|
||||
fn build(&self, app: &mut App) {
|
||||
// app.add_plugins(
|
||||
// StdbPlugin::default()
|
||||
// .with_uri("http://localhost:3000")
|
||||
// .with_module_name("jongline")
|
||||
// .with_run_fn(DbConnection::run_threaded),
|
||||
// );
|
||||
app
|
||||
// start stopper
|
||||
.init_state::<GameState>()
|
||||
|
|
|
|||
|
|
@ -3,15 +3,14 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_spacetimedb::StdbConnection;
|
||||
|
||||
// mod jongline_bindings;
|
||||
// use jongline_bindings::*;
|
||||
|
||||
pub mod game;
|
||||
pub mod tile;
|
||||
pub mod yakus;
|
||||
|
||||
mod stdb;
|
||||
|
||||
trait EnumNextCycle {
|
||||
fn next(&self) -> Self;
|
||||
}
|
||||
|
||||
// pub type SpacetimeDb<'a> = Res<'a, StdbConnection<DbConnection>>;
|
||||
pub type SpacetimeDB<'a> = Res<'a, StdbConnection<stdb::DbConnection>>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use bevy::{log::LogPlugin, prelude::*};
|
||||
use bevy_spacetimedb::{StdbConnection, StdbPlugin, TableMessages};
|
||||
use bevy_spacetimedb::{StdbConnection, StdbPlugin};
|
||||
use clap::{Parser, Subcommand};
|
||||
use tracing::Level;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
|
@ -47,14 +47,6 @@ fn main() {
|
|||
}
|
||||
};
|
||||
|
||||
// app.add_plugins(
|
||||
// StdbPlugin::default()
|
||||
// .with_uri("http://localhost:3000")
|
||||
// .with_module_name("jongline")
|
||||
// .with_run_fn(DbConnection::run_threaded)
|
||||
// .add_partial_table(RemoteTables::players, TableMessages::no_update()),
|
||||
// );
|
||||
|
||||
app.add_plugins(jong::game::Riichi);
|
||||
|
||||
app.run();
|
||||
|
|
|
|||
102
jong/src/stdb/add_player_reducer.rs
Normal file
102
jong/src/stdb/add_player_reducer.rs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// 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 AddPlayerArgs {
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
impl From<AddPlayerArgs> for super::Reducer {
|
||||
fn from(args: AddPlayerArgs) -> Self {
|
||||
Self::AddPlayer { name: args.name }
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AddPlayerArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct AddPlayerCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `add_player`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait add_player {
|
||||
/// Request that the remote module invoke the reducer `add_player` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_add_player`] callbacks.
|
||||
fn add_player(&self, name: Option<String>) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `add_player`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`AddPlayerCallbackId`] can be passed to [`Self::remove_on_add_player`]
|
||||
/// to cancel the callback.
|
||||
fn on_add_player(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &Option<String>) + Send + 'static,
|
||||
) -> AddPlayerCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_add_player`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_add_player(&self, callback: AddPlayerCallbackId);
|
||||
}
|
||||
|
||||
impl add_player for super::RemoteReducers {
|
||||
fn add_player(&self, name: Option<String>) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("add_player", AddPlayerArgs { name })
|
||||
}
|
||||
fn on_add_player(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &Option<String>) + Send + 'static,
|
||||
) -> AddPlayerCallbackId {
|
||||
AddPlayerCallbackId(self.imp.on_reducer(
|
||||
"add_player",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::AddPlayer { name },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, name)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_add_player(&self, callback: AddPlayerCallbackId) {
|
||||
self.imp.remove_on_reducer("add_player", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `add_player`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_add_player {
|
||||
/// Set the call-reducer flags for the reducer `add_player` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn add_player(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_add_player for super::SetReducerFlags {
|
||||
fn add_player(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("add_player", flags);
|
||||
}
|
||||
}
|
||||
100
jong/src/stdb/deal_hands_reducer.rs
Normal file
100
jong/src/stdb/deal_hands_reducer.rs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// 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 DealHandsArgs {}
|
||||
|
||||
impl From<DealHandsArgs> for super::Reducer {
|
||||
fn from(args: DealHandsArgs) -> Self {
|
||||
Self::DealHands
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DealHandsArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct DealHandsCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `deal_hands`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait deal_hands {
|
||||
/// Request that the remote module invoke the reducer `deal_hands` 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_deal_hands`] callbacks.
|
||||
fn deal_hands(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `deal_hands`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`DealHandsCallbackId`] can be passed to [`Self::remove_on_deal_hands`]
|
||||
/// to cancel the callback.
|
||||
fn on_deal_hands(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> DealHandsCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_deal_hands`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_deal_hands(&self, callback: DealHandsCallbackId);
|
||||
}
|
||||
|
||||
impl deal_hands for super::RemoteReducers {
|
||||
fn deal_hands(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("deal_hands", DealHandsArgs {})
|
||||
}
|
||||
fn on_deal_hands(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> DealHandsCallbackId {
|
||||
DealHandsCallbackId(self.imp.on_reducer(
|
||||
"deal_hands",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::DealHands {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_deal_hands(&self, callback: DealHandsCallbackId) {
|
||||
self.imp.remove_on_reducer("deal_hands", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `deal_hands`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_deal_hands {
|
||||
/// Set the call-reducer flags for the reducer `deal_hands` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn deal_hands(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_deal_hands for super::SetReducerFlags {
|
||||
fn deal_hands(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("deal_hands", flags);
|
||||
}
|
||||
}
|
||||
20
jong/src/stdb/dragon_type.rs
Normal file
20
jong/src/stdb/dragon_type.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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)]
|
||||
#[derive(Copy, Eq, Hash)]
|
||||
pub enum Dragon {
|
||||
Haku,
|
||||
|
||||
Hatsu,
|
||||
|
||||
Chun,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Dragon {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
145
jong/src/stdb/hand_table.rs
Normal file
145
jong/src/stdb/hand_table.rs
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::hand_type::Hand;
|
||||
use super::tile_type::Tile;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `hand`.
|
||||
///
|
||||
/// Obtain a handle from the [`HandTableAccess::hand`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.hand()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.hand().on_insert(...)`.
|
||||
pub struct HandTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Hand>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `hand`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait HandTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`HandTableHandle`], which mediates access to the table `hand`.
|
||||
fn hand(&self) -> HandTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl HandTableAccess for super::RemoteTables {
|
||||
fn hand(&self) -> HandTableHandle<'_> {
|
||||
HandTableHandle {
|
||||
imp: self.imp.get_table::<Hand>("hand"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct HandInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct HandDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for HandTableHandle<'ctx> {
|
||||
type Row = Hand;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Hand> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = HandInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> HandInsertCallbackId {
|
||||
HandInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: HandInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = HandDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> HandDeleteCallbackId {
|
||||
HandDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: HandDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<Hand>("hand");
|
||||
_table.add_unique_constraint::<__sdk::Identity>("player_ident", |row| &row.player_ident);
|
||||
}
|
||||
pub struct HandUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for HandTableHandle<'ctx> {
|
||||
type UpdateCallbackId = HandUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> HandUpdateCallbackId {
|
||||
HandUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: HandUpdateCallbackId) {
|
||||
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<Hand>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Hand>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Access to the `player_ident` unique index on the table `hand`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`HandPlayerIdentUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.hand().player_ident().find(...)`.
|
||||
pub struct HandPlayerIdentUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Hand, __sdk::Identity>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> HandTableHandle<'ctx> {
|
||||
/// Get a handle on the `player_ident` unique index on the table `hand`.
|
||||
pub fn player_ident(&self) -> HandPlayerIdentUnique<'ctx> {
|
||||
HandPlayerIdentUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<__sdk::Identity>("player_ident"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> HandPlayerIdentUnique<'ctx> {
|
||||
/// Find the subscribed row whose `player_ident` 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<Hand> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
18
jong/src/stdb/hand_type.rs
Normal file
18
jong/src/stdb/hand_type.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::tile_type::Tile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Hand {
|
||||
pub player_ident: __sdk::Identity,
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Hand {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
105
jong/src/stdb/insert_wall_reducer.rs
Normal file
105
jong/src/stdb/insert_wall_reducer.rs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// 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 InsertWallArgs {
|
||||
pub player_ids: Vec<u32>,
|
||||
}
|
||||
|
||||
impl From<InsertWallArgs> for super::Reducer {
|
||||
fn from(args: InsertWallArgs) -> Self {
|
||||
Self::InsertWall {
|
||||
player_ids: args.player_ids,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for InsertWallArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct InsertWallCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `insert_wall`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait insert_wall {
|
||||
/// Request that the remote module invoke the reducer `insert_wall` 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_insert_wall`] callbacks.
|
||||
fn insert_wall(&self, player_ids: Vec<u32>) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `insert_wall`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`InsertWallCallbackId`] can be passed to [`Self::remove_on_insert_wall`]
|
||||
/// to cancel the callback.
|
||||
fn on_insert_wall(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &Vec<u32>) + Send + 'static,
|
||||
) -> InsertWallCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_insert_wall`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_insert_wall(&self, callback: InsertWallCallbackId);
|
||||
}
|
||||
|
||||
impl insert_wall for super::RemoteReducers {
|
||||
fn insert_wall(&self, player_ids: Vec<u32>) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("insert_wall", InsertWallArgs { player_ids })
|
||||
}
|
||||
fn on_insert_wall(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &Vec<u32>) + Send + 'static,
|
||||
) -> InsertWallCallbackId {
|
||||
InsertWallCallbackId(self.imp.on_reducer(
|
||||
"insert_wall",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::InsertWall { player_ids },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, player_ids)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_insert_wall(&self, callback: InsertWallCallbackId) {
|
||||
self.imp.remove_on_reducer("insert_wall", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `insert_wall`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_insert_wall {
|
||||
/// Set the call-reducer flags for the reducer `insert_wall` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn insert_wall(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_insert_wall for super::SetReducerFlags {
|
||||
fn insert_wall(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("insert_wall", flags);
|
||||
}
|
||||
}
|
||||
105
jong/src/stdb/join_or_create_lobby_reducer.rs
Normal file
105
jong/src/stdb/join_or_create_lobby_reducer.rs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// 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 JoinOrCreateLobbyArgs {
|
||||
pub lobby: Option<u32>,
|
||||
}
|
||||
|
||||
impl From<JoinOrCreateLobbyArgs> for super::Reducer {
|
||||
fn from(args: JoinOrCreateLobbyArgs) -> Self {
|
||||
Self::JoinOrCreateLobby { lobby: args.lobby }
|
||||
}
|
||||
}
|
||||
|
||||
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`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait join_or_create_lobby {
|
||||
/// Request that the remote module invoke the reducer `join_or_create_lobby` 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_join_or_create_lobby`] callbacks.
|
||||
fn join_or_create_lobby(&self, lobby: Option<u32>) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// 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(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &Option<u32>) + Send + 'static,
|
||||
) -> JoinOrCreateLobbyCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId);
|
||||
}
|
||||
|
||||
impl join_or_create_lobby for super::RemoteReducers {
|
||||
fn join_or_create_lobby(&self, lobby: Option<u32>) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby })
|
||||
}
|
||||
fn on_join_or_create_lobby(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &Option<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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, lobby)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) {
|
||||
self.imp
|
||||
.remove_on_reducer("join_or_create_lobby", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[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) {
|
||||
self.imp
|
||||
.set_call_reducer_flags("join_or_create_lobby", flags);
|
||||
}
|
||||
}
|
||||
142
jong/src/stdb/lobby_table.rs
Normal file
142
jong/src/stdb/lobby_table.rs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
// 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::lobby_type::Lobby;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `lobby`.
|
||||
///
|
||||
/// Obtain a handle from the [`LobbyTableAccess::lobby`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.lobby()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.lobby().on_insert(...)`.
|
||||
pub struct LobbyTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Lobby>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `lobby`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait LobbyTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`LobbyTableHandle`], which mediates access to the table `lobby`.
|
||||
fn lobby(&self) -> LobbyTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl LobbyTableAccess for super::RemoteTables {
|
||||
fn lobby(&self) -> LobbyTableHandle<'_> {
|
||||
LobbyTableHandle {
|
||||
imp: self.imp.get_table::<Lobby>("lobby"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct LobbyInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct LobbyDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
|
||||
type Row = Lobby;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Lobby> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = LobbyInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> LobbyInsertCallbackId {
|
||||
LobbyInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: LobbyInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = LobbyDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> LobbyDeleteCallbackId {
|
||||
LobbyDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: LobbyDeleteCallbackId) {
|
||||
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::<Lobby>("lobby");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct LobbyUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> {
|
||||
type UpdateCallbackId = LobbyUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> LobbyUpdateCallbackId {
|
||||
LobbyUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: LobbyUpdateCallbackId) {
|
||||
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<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.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.lobby().id().find(...)`.
|
||||
pub struct LobbyIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Lobby, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> LobbyTableHandle<'ctx> {
|
||||
/// Get a handle on the `id` unique index on the table `lobby`.
|
||||
pub fn id(&self) -> LobbyIdUnique<'ctx> {
|
||||
LobbyIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> LobbyIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<Lobby> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
16
jong/src/stdb/lobby_type.rs
Normal file
16
jong/src/stdb/lobby_type.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Lobby {
|
||||
pub id: u32,
|
||||
pub host: __sdk::Identity,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Lobby {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
978
jong/src/stdb/mod.rs
Normal file
978
jong/src/stdb/mod.rs
Normal file
|
|
@ -0,0 +1,978 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
// This was generated using spacetimedb cli version 1.11.3 (commit 02449737ca3b29e7e39679fccbef541a50f32094).
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
pub mod add_player_reducer;
|
||||
pub mod deal_hands_reducer;
|
||||
pub mod dragon_type;
|
||||
pub mod hand_table;
|
||||
pub mod hand_type;
|
||||
pub mod insert_wall_reducer;
|
||||
pub mod join_or_create_lobby_reducer;
|
||||
pub mod lobby_table;
|
||||
pub mod lobby_type;
|
||||
pub mod player_table;
|
||||
pub mod player_type;
|
||||
pub mod pond_table;
|
||||
pub mod pond_type;
|
||||
pub mod rank_type;
|
||||
pub mod set_name_reducer;
|
||||
pub mod shuffle_wall_reducer;
|
||||
pub mod sort_hand_reducer;
|
||||
pub mod suit_type;
|
||||
pub mod tile_type;
|
||||
pub mod wall_table;
|
||||
pub mod wall_type;
|
||||
pub mod wind_type;
|
||||
|
||||
pub use add_player_reducer::{add_player, set_flags_for_add_player, AddPlayerCallbackId};
|
||||
pub use deal_hands_reducer::{deal_hands, set_flags_for_deal_hands, DealHandsCallbackId};
|
||||
pub use dragon_type::Dragon;
|
||||
pub use hand_table::*;
|
||||
pub use hand_type::Hand;
|
||||
pub use insert_wall_reducer::{insert_wall, set_flags_for_insert_wall, InsertWallCallbackId};
|
||||
pub use join_or_create_lobby_reducer::{
|
||||
join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId,
|
||||
};
|
||||
pub use lobby_table::*;
|
||||
pub use lobby_type::Lobby;
|
||||
pub use player_table::*;
|
||||
pub use player_type::Player;
|
||||
pub use pond_table::*;
|
||||
pub use pond_type::Pond;
|
||||
pub use rank_type::Rank;
|
||||
pub use set_name_reducer::{set_flags_for_set_name, set_name, SetNameCallbackId};
|
||||
pub use shuffle_wall_reducer::{set_flags_for_shuffle_wall, shuffle_wall, ShuffleWallCallbackId};
|
||||
pub use sort_hand_reducer::{set_flags_for_sort_hand, sort_hand, SortHandCallbackId};
|
||||
pub use suit_type::Suit;
|
||||
pub use tile_type::Tile;
|
||||
pub use wall_table::*;
|
||||
pub use wall_type::Wall;
|
||||
pub use wind_type::Wind;
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
|
||||
/// One of the reducers defined by this module.
|
||||
///
|
||||
/// Contained within a [`__sdk::ReducerEvent`] in [`EventContext`]s for reducer events
|
||||
/// to indicate which reducer caused the event.
|
||||
|
||||
pub enum Reducer {
|
||||
AddPlayer { name: Option<String> },
|
||||
DealHands,
|
||||
InsertWall { player_ids: Vec<u32> },
|
||||
JoinOrCreateLobby { lobby: Option<u32> },
|
||||
SetName { name: String },
|
||||
ShuffleWall,
|
||||
SortHand,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Reducer {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::Reducer for Reducer {
|
||||
fn reducer_name(&self) -> &'static str {
|
||||
match self {
|
||||
Reducer::AddPlayer { .. } => "add_player",
|
||||
Reducer::DealHands => "deal_hands",
|
||||
Reducer::InsertWall { .. } => "insert_wall",
|
||||
Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby",
|
||||
Reducer::SetName { .. } => "set_name",
|
||||
Reducer::ShuffleWall => "shuffle_wall",
|
||||
Reducer::SortHand => "sort_hand",
|
||||
_ => 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_player" => Ok(
|
||||
__sdk::parse_reducer_args::<add_player_reducer::AddPlayerArgs>(
|
||||
"add_player",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"deal_hands" => Ok(
|
||||
__sdk::parse_reducer_args::<deal_hands_reducer::DealHandsArgs>(
|
||||
"deal_hands",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"insert_wall" => Ok(
|
||||
__sdk::parse_reducer_args::<insert_wall_reducer::InsertWallArgs>(
|
||||
"insert_wall",
|
||||
&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_name" => Ok(__sdk::parse_reducer_args::<set_name_reducer::SetNameArgs>(
|
||||
"set_name",
|
||||
&value.args,
|
||||
)?
|
||||
.into()),
|
||||
"shuffle_wall" => Ok(
|
||||
__sdk::parse_reducer_args::<shuffle_wall_reducer::ShuffleWallArgs>(
|
||||
"shuffle_wall",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
"sort_hand" => Ok(
|
||||
__sdk::parse_reducer_args::<sort_hand_reducer::SortHandArgs>(
|
||||
"sort_hand",
|
||||
&value.args,
|
||||
)?
|
||||
.into(),
|
||||
),
|
||||
unknown => {
|
||||
Err(
|
||||
__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo")
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[allow(non_snake_case)]
|
||||
#[doc(hidden)]
|
||||
pub struct DbUpdate {
|
||||
hand: __sdk::TableUpdate<Hand>,
|
||||
lobby: __sdk::TableUpdate<Lobby>,
|
||||
player: __sdk::TableUpdate<Player>,
|
||||
pond: __sdk::TableUpdate<Pond>,
|
||||
wall: __sdk::TableUpdate<Wall>,
|
||||
}
|
||||
|
||||
impl TryFrom<__ws::DatabaseUpdate<__ws::BsatnFormat>> for DbUpdate {
|
||||
type Error = __sdk::Error;
|
||||
fn try_from(raw: __ws::DatabaseUpdate<__ws::BsatnFormat>) -> Result<Self, Self::Error> {
|
||||
let mut db_update = DbUpdate::default();
|
||||
for table_update in raw.tables {
|
||||
match &table_update.table_name[..] {
|
||||
"hand" => db_update
|
||||
.hand
|
||||
.append(hand_table::parse_table_update(table_update)?),
|
||||
"lobby" => db_update
|
||||
.lobby
|
||||
.append(lobby_table::parse_table_update(table_update)?),
|
||||
"player" => db_update
|
||||
.player
|
||||
.append(player_table::parse_table_update(table_update)?),
|
||||
"pond" => db_update
|
||||
.pond
|
||||
.append(pond_table::parse_table_update(table_update)?),
|
||||
"wall" => db_update
|
||||
.wall
|
||||
.append(wall_table::parse_table_update(table_update)?),
|
||||
|
||||
unknown => {
|
||||
return Err(__sdk::InternalError::unknown_name(
|
||||
"table",
|
||||
unknown,
|
||||
"DatabaseUpdate",
|
||||
)
|
||||
.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(db_update)
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DbUpdate {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbUpdate for DbUpdate {
|
||||
fn apply_to_client_cache(
|
||||
&self,
|
||||
cache: &mut __sdk::ClientCache<RemoteModule>,
|
||||
) -> AppliedDiff<'_> {
|
||||
let mut diff = AppliedDiff::default();
|
||||
|
||||
diff.hand = cache
|
||||
.apply_diff_to_table::<Hand>("hand", &self.hand)
|
||||
.with_updates_by_pk(|row| &row.player_ident);
|
||||
diff.lobby = cache
|
||||
.apply_diff_to_table::<Lobby>("lobby", &self.lobby)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
diff.player = cache
|
||||
.apply_diff_to_table::<Player>("player", &self.player)
|
||||
.with_updates_by_pk(|row| &row.identity);
|
||||
diff.pond = cache.apply_diff_to_table::<Pond>("pond", &self.pond);
|
||||
diff.wall = cache
|
||||
.apply_diff_to_table::<Wall>("wall", &self.wall)
|
||||
.with_updates_by_pk(|row| &row.id);
|
||||
|
||||
diff
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[allow(non_snake_case)]
|
||||
#[doc(hidden)]
|
||||
pub struct AppliedDiff<'r> {
|
||||
hand: __sdk::TableAppliedDiff<'r, Hand>,
|
||||
lobby: __sdk::TableAppliedDiff<'r, Lobby>,
|
||||
player: __sdk::TableAppliedDiff<'r, Player>,
|
||||
pond: __sdk::TableAppliedDiff<'r, Pond>,
|
||||
wall: __sdk::TableAppliedDiff<'r, Wall>,
|
||||
__unused: std::marker::PhantomData<&'r ()>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AppliedDiff<'_> {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
|
||||
fn invoke_row_callbacks(
|
||||
&self,
|
||||
event: &EventContext,
|
||||
callbacks: &mut __sdk::DbCallbacks<RemoteModule>,
|
||||
) {
|
||||
callbacks.invoke_table_row_callbacks::<Hand>("hand", &self.hand, event);
|
||||
callbacks.invoke_table_row_callbacks::<Lobby>("lobby", &self.lobby, event);
|
||||
callbacks.invoke_table_row_callbacks::<Player>("player", &self.player, event);
|
||||
callbacks.invoke_table_row_callbacks::<Pond>("pond", &self.pond, event);
|
||||
callbacks.invoke_table_row_callbacks::<Wall>("wall", &self.wall, event);
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct RemoteModule;
|
||||
|
||||
impl __sdk::InModule for RemoteModule {
|
||||
type Module = Self;
|
||||
}
|
||||
|
||||
/// The `reducers` field of [`EventContext`] and [`DbConnection`],
|
||||
/// with methods provided by extension traits for each reducer defined by the module.
|
||||
pub struct RemoteReducers {
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RemoteReducers {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
/// The `procedures` field of [`DbConnection`] and other [`DbContext`] types,
|
||||
/// with methods provided by extension traits for each procedure defined by the module.
|
||||
pub struct RemoteProcedures {
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
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 {
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for RemoteTables {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
/// A connection to a remote module, including a materialized view of a subset of the database.
|
||||
///
|
||||
/// Connect to a remote module by calling [`DbConnection::builder`]
|
||||
/// and using the [`__sdk::DbConnectionBuilder`] builder-pattern constructor.
|
||||
///
|
||||
/// You must explicitly advance the connection by calling any one of:
|
||||
///
|
||||
/// - [`DbConnection::frame_tick`].
|
||||
/// - [`DbConnection::run_threaded`].
|
||||
/// - [`DbConnection::run_async`].
|
||||
/// - [`DbConnection::advance_one_message`].
|
||||
/// - [`DbConnection::advance_one_message_blocking`].
|
||||
/// - [`DbConnection::advance_one_message_async`].
|
||||
///
|
||||
/// Which of these methods you should call depends on the specific needs of your application,
|
||||
/// but you must call one of them, or else the connection will never progress.
|
||||
pub struct DbConnection {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
pub db: RemoteTables,
|
||||
/// 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,
|
||||
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DbConnection {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for DbConnection {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl DbConnection {
|
||||
/// Builder-pattern constructor for a connection to a remote module.
|
||||
///
|
||||
/// See [`__sdk::DbConnectionBuilder`] for required and optional configuration for the new connection.
|
||||
pub fn builder() -> __sdk::DbConnectionBuilder<RemoteModule> {
|
||||
__sdk::DbConnectionBuilder::new()
|
||||
}
|
||||
|
||||
/// If any WebSocket messages are waiting, process one of them.
|
||||
///
|
||||
/// Returns `true` if a message was processed, or `false` if the queue is empty.
|
||||
/// Callers should invoke this message in a loop until it returns `false`
|
||||
/// or for as much time is available to process messages.
|
||||
///
|
||||
/// Returns an error if the connection is disconnected.
|
||||
/// If the disconnection in question was normal,
|
||||
/// i.e. the result of a call to [`__sdk::DbContext::disconnect`],
|
||||
/// the returned error will be downcastable to [`__sdk::DisconnectedError`].
|
||||
///
|
||||
/// This is a low-level primitive exposed for power users who need significant control over scheduling.
|
||||
/// Most applications should call [`Self::frame_tick`] each frame
|
||||
/// to fully exhaust the queue whenever time is available.
|
||||
pub fn advance_one_message(&self) -> __sdk::Result<bool> {
|
||||
self.imp.advance_one_message()
|
||||
}
|
||||
|
||||
/// Process one WebSocket message, potentially blocking the current thread until one is received.
|
||||
///
|
||||
/// Returns an error if the connection is disconnected.
|
||||
/// If the disconnection in question was normal,
|
||||
/// i.e. the result of a call to [`__sdk::DbContext::disconnect`],
|
||||
/// the returned error will be downcastable to [`__sdk::DisconnectedError`].
|
||||
///
|
||||
/// This is a low-level primitive exposed for power users who need significant control over scheduling.
|
||||
/// Most applications should call [`Self::run_threaded`] to spawn a thread
|
||||
/// which advances the connection automatically.
|
||||
pub fn advance_one_message_blocking(&self) -> __sdk::Result<()> {
|
||||
self.imp.advance_one_message_blocking()
|
||||
}
|
||||
|
||||
/// Process one WebSocket message, `await`ing until one is received.
|
||||
///
|
||||
/// Returns an error if the connection is disconnected.
|
||||
/// If the disconnection in question was normal,
|
||||
/// i.e. the result of a call to [`__sdk::DbContext::disconnect`],
|
||||
/// the returned error will be downcastable to [`__sdk::DisconnectedError`].
|
||||
///
|
||||
/// This is a low-level primitive exposed for power users who need significant control over scheduling.
|
||||
/// Most applications should call [`Self::run_async`] to run an `async` loop
|
||||
/// which advances the connection when polled.
|
||||
pub async fn advance_one_message_async(&self) -> __sdk::Result<()> {
|
||||
self.imp.advance_one_message_async().await
|
||||
}
|
||||
|
||||
/// Process all WebSocket messages waiting in the queue,
|
||||
/// then return without `await`ing or blocking the current thread.
|
||||
pub fn frame_tick(&self) -> __sdk::Result<()> {
|
||||
self.imp.frame_tick()
|
||||
}
|
||||
|
||||
/// Spawn a thread which processes WebSocket messages as they are received.
|
||||
pub fn run_threaded(&self) -> std::thread::JoinHandle<()> {
|
||||
self.imp.run_threaded()
|
||||
}
|
||||
|
||||
/// Run an `async` loop which processes WebSocket messages when polled.
|
||||
pub async fn run_async(&self) -> __sdk::Result<()> {
|
||||
self.imp.run_async().await
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::DbConnection for DbConnection {
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>) -> Self {
|
||||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A handle on a subscribed query.
|
||||
// TODO: Document this better after implementing the new subscription API.
|
||||
#[derive(Clone)]
|
||||
pub struct SubscriptionHandle {
|
||||
imp: __sdk::SubscriptionHandleImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SubscriptionHandle {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::SubscriptionHandle for SubscriptionHandle {
|
||||
fn new(imp: __sdk::SubscriptionHandleImpl<RemoteModule>) -> Self {
|
||||
Self { imp }
|
||||
}
|
||||
|
||||
/// Returns true if this subscription has been terminated due to an unsubscribe call or an error.
|
||||
fn is_ended(&self) -> bool {
|
||||
self.imp.is_ended()
|
||||
}
|
||||
|
||||
/// Returns true if this subscription has been applied and has not yet been unsubscribed.
|
||||
fn is_active(&self) -> bool {
|
||||
self.imp.is_active()
|
||||
}
|
||||
|
||||
/// Unsubscribe from the query controlled by this `SubscriptionHandle`,
|
||||
/// then run `on_end` when its rows are removed from the client cache.
|
||||
fn unsubscribe_then(self, on_end: __sdk::OnEndedCallback<RemoteModule>) -> __sdk::Result<()> {
|
||||
self.imp.unsubscribe_then(Some(on_end))
|
||||
}
|
||||
|
||||
fn unsubscribe(self) -> __sdk::Result<()> {
|
||||
self.imp.unsubscribe_then(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Alias trait for a [`__sdk::DbContext`] connected to this module,
|
||||
/// with that trait's associated types bounded to this module's concrete types.
|
||||
///
|
||||
/// Users can use this trait as a boundary on definitions which should accept
|
||||
/// either a [`DbConnection`] or an [`EventContext`] and operate on either.
|
||||
pub trait RemoteDbContext:
|
||||
__sdk::DbContext<
|
||||
DbView = RemoteTables,
|
||||
Reducers = RemoteReducers,
|
||||
SetReducerFlags = SetReducerFlags,
|
||||
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
|
||||
>
|
||||
{
|
||||
}
|
||||
impl<
|
||||
Ctx: __sdk::DbContext<
|
||||
DbView = RemoteTables,
|
||||
Reducers = RemoteReducers,
|
||||
SetReducerFlags = SetReducerFlags,
|
||||
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
|
||||
>,
|
||||
> RemoteDbContext for Ctx
|
||||
{
|
||||
}
|
||||
|
||||
/// An [`__sdk::DbContext`] augmented with a [`__sdk::Event`],
|
||||
/// passed to [`__sdk::Table::on_insert`], [`__sdk::Table::on_delete`] and [`__sdk::TableWithPrimaryKey::on_update`] callbacks.
|
||||
pub struct EventContext {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
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.
|
||||
pub event: __sdk::Event<Reducer>,
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::AbstractEventContext for EventContext {
|
||||
type Event = __sdk::Event<Reducer>;
|
||||
fn event(&self) -> &Self::Event {
|
||||
&self.event
|
||||
}
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>, event: Self::Event) -> Self {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for EventContext {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for EventContext {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::EventContext for EventContext {}
|
||||
|
||||
/// An [`__sdk::DbContext`] augmented with a [`__sdk::ReducerEvent`],
|
||||
/// passed to on-reducer callbacks.
|
||||
pub struct ReducerEventContext {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
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.
|
||||
pub event: __sdk::ReducerEvent<Reducer>,
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::AbstractEventContext for ReducerEventContext {
|
||||
type Event = __sdk::ReducerEvent<Reducer>;
|
||||
fn event(&self) -> &Self::Event {
|
||||
&self.event
|
||||
}
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>, event: Self::Event) -> Self {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ReducerEventContext {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for ReducerEventContext {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::ReducerEventContext for ReducerEventContext {}
|
||||
|
||||
/// An [`__sdk::DbContext`] passed to procedure callbacks.
|
||||
pub struct ProcedureEventContext {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
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>,
|
||||
}
|
||||
|
||||
impl __sdk::AbstractEventContext for ProcedureEventContext {
|
||||
type Event = ();
|
||||
fn event(&self) -> &Self::Event {
|
||||
&()
|
||||
}
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>, _event: Self::Event) -> Self {
|
||||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ProcedureEventContext {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for ProcedureEventContext {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::ProcedureEventContext for ProcedureEventContext {}
|
||||
|
||||
/// An [`__sdk::DbContext`] passed to [`__sdk::SubscriptionBuilder::on_applied`] and [`SubscriptionHandle::unsubscribe_then`] callbacks.
|
||||
pub struct SubscriptionEventContext {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
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>,
|
||||
}
|
||||
|
||||
impl __sdk::AbstractEventContext for SubscriptionEventContext {
|
||||
type Event = ();
|
||||
fn event(&self) -> &Self::Event {
|
||||
&()
|
||||
}
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>, _event: Self::Event) -> Self {
|
||||
Self {
|
||||
db: RemoteTables { imp: imp.clone() },
|
||||
reducers: RemoteReducers { imp: imp.clone() },
|
||||
procedures: RemoteProcedures { imp: imp.clone() },
|
||||
set_reducer_flags: SetReducerFlags { imp: imp.clone() },
|
||||
imp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SubscriptionEventContext {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for SubscriptionEventContext {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::SubscriptionEventContext for SubscriptionEventContext {}
|
||||
|
||||
/// An [`__sdk::DbContext`] augmented with a [`__sdk::Error`],
|
||||
/// passed to [`__sdk::DbConnectionBuilder::on_disconnect`], [`__sdk::DbConnectionBuilder::on_connect_error`] and [`__sdk::SubscriptionBuilder::on_error`] callbacks.
|
||||
pub struct ErrorContext {
|
||||
/// Access to tables defined by the module via extension traits implemented for [`RemoteTables`].
|
||||
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.
|
||||
pub event: Option<__sdk::Error>,
|
||||
imp: __sdk::DbContextImpl<RemoteModule>,
|
||||
}
|
||||
|
||||
impl __sdk::AbstractEventContext for ErrorContext {
|
||||
type Event = Option<__sdk::Error>;
|
||||
fn event(&self) -> &Self::Event {
|
||||
&self.event
|
||||
}
|
||||
fn new(imp: __sdk::DbContextImpl<RemoteModule>, event: Self::Event) -> Self {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ErrorContext {
|
||||
type Module = RemoteModule;
|
||||
}
|
||||
|
||||
impl __sdk::DbContext for ErrorContext {
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type Procedures = RemoteProcedures;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
|
||||
fn db(&self) -> &Self::DbView {
|
||||
&self.db
|
||||
}
|
||||
fn reducers(&self) -> &Self::Reducers {
|
||||
&self.reducers
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
fn disconnect(&self) -> __sdk::Result<()> {
|
||||
self.imp.disconnect()
|
||||
}
|
||||
|
||||
type SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>;
|
||||
|
||||
fn subscription_builder(&self) -> Self::SubscriptionBuilder {
|
||||
__sdk::SubscriptionBuilder::new(&self.imp)
|
||||
}
|
||||
|
||||
fn try_identity(&self) -> Option<__sdk::Identity> {
|
||||
self.imp.try_identity()
|
||||
}
|
||||
fn connection_id(&self) -> __sdk::ConnectionId {
|
||||
self.imp.connection_id()
|
||||
}
|
||||
fn try_connection_id(&self) -> Option<__sdk::ConnectionId> {
|
||||
self.imp.try_connection_id()
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::ErrorContext for ErrorContext {}
|
||||
|
||||
impl __sdk::SpacetimeModule for RemoteModule {
|
||||
type DbConnection = DbConnection;
|
||||
type EventContext = EventContext;
|
||||
type ReducerEventContext = ReducerEventContext;
|
||||
type ProcedureEventContext = ProcedureEventContext;
|
||||
type SubscriptionEventContext = SubscriptionEventContext;
|
||||
type ErrorContext = ErrorContext;
|
||||
type Reducer = Reducer;
|
||||
type DbView = RemoteTables;
|
||||
type Reducers = RemoteReducers;
|
||||
type SetReducerFlags = SetReducerFlags;
|
||||
type DbUpdate = DbUpdate;
|
||||
type AppliedDiff<'r> = AppliedDiff<'r>;
|
||||
type SubscriptionHandle = SubscriptionHandle;
|
||||
|
||||
fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
|
||||
hand_table::register_table(client_cache);
|
||||
lobby_table::register_table(client_cache);
|
||||
player_table::register_table(client_cache);
|
||||
pond_table::register_table(client_cache);
|
||||
wall_table::register_table(client_cache);
|
||||
}
|
||||
}
|
||||
144
jong/src/stdb/player_table.rs
Normal file
144
jong/src/stdb/player_table.rs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::player_type::Player;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `player`.
|
||||
///
|
||||
/// Obtain a handle from the [`PlayerTableAccess::player`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.player()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.player().on_insert(...)`.
|
||||
pub struct PlayerTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Player>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `player`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait PlayerTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`PlayerTableHandle`], which mediates access to the table `player`.
|
||||
fn player(&self) -> PlayerTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl PlayerTableAccess for super::RemoteTables {
|
||||
fn player(&self) -> PlayerTableHandle<'_> {
|
||||
PlayerTableHandle {
|
||||
imp: self.imp.get_table::<Player>("player"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PlayerInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct PlayerDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> {
|
||||
type Row = Player;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Player> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = PlayerInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> PlayerInsertCallbackId {
|
||||
PlayerInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: PlayerInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = PlayerDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> PlayerDeleteCallbackId {
|
||||
PlayerDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: PlayerDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[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::<__sdk::Identity>("identity", |row| &row.identity);
|
||||
}
|
||||
pub struct PlayerUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> {
|
||||
type UpdateCallbackId = PlayerUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> PlayerUpdateCallbackId {
|
||||
PlayerUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: PlayerUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[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 `identity` unique index on the table `player`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`PlayerIdentityUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.player().identity().find(...)`.
|
||||
pub struct PlayerIdentityUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Player, __sdk::Identity>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> PlayerTableHandle<'ctx> {
|
||||
/// Get a handle on the `identity` unique index on the table `player`.
|
||||
pub fn identity(&self) -> PlayerIdentityUnique<'ctx> {
|
||||
PlayerIdentityUnique {
|
||||
imp: self
|
||||
.imp
|
||||
.get_unique_constraint::<__sdk::Identity>("identity"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> PlayerIdentityUnique<'ctx> {
|
||||
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &__sdk::Identity) -> Option<Player> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
17
jong/src/stdb/player_type.rs
Normal file
17
jong/src/stdb/player_type.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Player {
|
||||
pub identity: __sdk::Identity,
|
||||
pub name: Option<String>,
|
||||
pub lobby_id: u32,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Player {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
96
jong/src/stdb/pond_table.rs
Normal file
96
jong/src/stdb/pond_table.rs
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
// 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::pond_type::Pond;
|
||||
use super::tile_type::Tile;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `pond`.
|
||||
///
|
||||
/// Obtain a handle from the [`PondTableAccess::pond`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.pond()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.pond().on_insert(...)`.
|
||||
pub struct PondTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Pond>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `pond`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait PondTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`PondTableHandle`], which mediates access to the table `pond`.
|
||||
fn pond(&self) -> PondTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl PondTableAccess for super::RemoteTables {
|
||||
fn pond(&self) -> PondTableHandle<'_> {
|
||||
PondTableHandle {
|
||||
imp: self.imp.get_table::<Pond>("pond"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PondInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct PondDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for PondTableHandle<'ctx> {
|
||||
type Row = Pond;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Pond> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = PondInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> PondInsertCallbackId {
|
||||
PondInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: PondInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = PondDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> PondDeleteCallbackId {
|
||||
PondDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: PondDeleteCallbackId) {
|
||||
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::<Pond>("pond");
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<Pond>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Pond>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
17
jong/src/stdb/pond_type.rs
Normal file
17
jong/src/stdb/pond_type.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::tile_type::Tile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Pond {
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Pond {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
15
jong/src/stdb/rank_type.rs
Normal file
15
jong/src/stdb/rank_type.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Rank {
|
||||
pub number: u8,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Rank {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
102
jong/src/stdb/set_name_reducer.rs
Normal file
102
jong/src/stdb/set_name_reducer.rs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// 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 SetNameArgs {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl From<SetNameArgs> for super::Reducer {
|
||||
fn from(args: SetNameArgs) -> Self {
|
||||
Self::SetName { name: args.name }
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SetNameArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct SetNameCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `set_name`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait set_name {
|
||||
/// Request that the remote module invoke the reducer `set_name` 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_set_name`] callbacks.
|
||||
fn set_name(&self, name: String) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `set_name`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`SetNameCallbackId`] can be passed to [`Self::remove_on_set_name`]
|
||||
/// to cancel the callback.
|
||||
fn on_set_name(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &String) + Send + 'static,
|
||||
) -> SetNameCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_set_name`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_set_name(&self, callback: SetNameCallbackId);
|
||||
}
|
||||
|
||||
impl set_name for super::RemoteReducers {
|
||||
fn set_name(&self, name: String) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("set_name", SetNameArgs { name })
|
||||
}
|
||||
fn on_set_name(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &String) + Send + 'static,
|
||||
) -> SetNameCallbackId {
|
||||
SetNameCallbackId(self.imp.on_reducer(
|
||||
"set_name",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::SetName { name },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, name)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_set_name(&self, callback: SetNameCallbackId) {
|
||||
self.imp.remove_on_reducer("set_name", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `set_name`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_set_name {
|
||||
/// Set the call-reducer flags for the reducer `set_name` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn set_name(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_set_name for super::SetReducerFlags {
|
||||
fn set_name(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("set_name", flags);
|
||||
}
|
||||
}
|
||||
100
jong/src/stdb/shuffle_wall_reducer.rs
Normal file
100
jong/src/stdb/shuffle_wall_reducer.rs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// 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 ShuffleWallArgs {}
|
||||
|
||||
impl From<ShuffleWallArgs> for super::Reducer {
|
||||
fn from(args: ShuffleWallArgs) -> Self {
|
||||
Self::ShuffleWall
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ShuffleWallArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct ShuffleWallCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `shuffle_wall`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait shuffle_wall {
|
||||
/// Request that the remote module invoke the reducer `shuffle_wall` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_shuffle_wall`] callbacks.
|
||||
fn shuffle_wall(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `shuffle_wall`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`ShuffleWallCallbackId`] can be passed to [`Self::remove_on_shuffle_wall`]
|
||||
/// to cancel the callback.
|
||||
fn on_shuffle_wall(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> ShuffleWallCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_shuffle_wall`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_shuffle_wall(&self, callback: ShuffleWallCallbackId);
|
||||
}
|
||||
|
||||
impl shuffle_wall for super::RemoteReducers {
|
||||
fn shuffle_wall(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("shuffle_wall", ShuffleWallArgs {})
|
||||
}
|
||||
fn on_shuffle_wall(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> ShuffleWallCallbackId {
|
||||
ShuffleWallCallbackId(self.imp.on_reducer(
|
||||
"shuffle_wall",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::ShuffleWall {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_shuffle_wall(&self, callback: ShuffleWallCallbackId) {
|
||||
self.imp.remove_on_reducer("shuffle_wall", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `shuffle_wall`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_shuffle_wall {
|
||||
/// Set the call-reducer flags for the reducer `shuffle_wall` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn shuffle_wall(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_shuffle_wall for super::SetReducerFlags {
|
||||
fn shuffle_wall(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("shuffle_wall", flags);
|
||||
}
|
||||
}
|
||||
100
jong/src/stdb/sort_hand_reducer.rs
Normal file
100
jong/src/stdb/sort_hand_reducer.rs
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// 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 SortHandArgs {}
|
||||
|
||||
impl From<SortHandArgs> for super::Reducer {
|
||||
fn from(args: SortHandArgs) -> Self {
|
||||
Self::SortHand
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SortHandArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct SortHandCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `sort_hand`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait sort_hand {
|
||||
/// Request that the remote module invoke the reducer `sort_hand` 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_sort_hand`] callbacks.
|
||||
fn sort_hand(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `sort_hand`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`SortHandCallbackId`] can be passed to [`Self::remove_on_sort_hand`]
|
||||
/// to cancel the callback.
|
||||
fn on_sort_hand(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> SortHandCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_sort_hand`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_sort_hand(&self, callback: SortHandCallbackId);
|
||||
}
|
||||
|
||||
impl sort_hand for super::RemoteReducers {
|
||||
fn sort_hand(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("sort_hand", SortHandArgs {})
|
||||
}
|
||||
fn on_sort_hand(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> SortHandCallbackId {
|
||||
SortHandCallbackId(self.imp.on_reducer(
|
||||
"sort_hand",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::SortHand {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_sort_hand(&self, callback: SortHandCallbackId) {
|
||||
self.imp.remove_on_reducer("sort_hand", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `sort_hand`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_sort_hand {
|
||||
/// Set the call-reducer flags for the reducer `sort_hand` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn sort_hand(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_sort_hand for super::SetReducerFlags {
|
||||
fn sort_hand(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("sort_hand", flags);
|
||||
}
|
||||
}
|
||||
27
jong/src/stdb/suit_type.rs
Normal file
27
jong/src/stdb/suit_type.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::dragon_type::Dragon;
|
||||
use super::rank_type::Rank;
|
||||
use super::wind_type::Wind;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub enum Suit {
|
||||
Man(Rank),
|
||||
|
||||
Pin(Rank),
|
||||
|
||||
Sou(Rank),
|
||||
|
||||
Wind(Wind),
|
||||
|
||||
Dragon(Dragon),
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Suit {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
17
jong/src/stdb/tile_type.rs
Normal file
17
jong/src/stdb/tile_type.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::suit_type::Suit;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Tile {
|
||||
pub suit: Suit,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Tile {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
143
jong/src/stdb/wall_table.rs
Normal file
143
jong/src/stdb/wall_table.rs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// 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::tile_type::Tile;
|
||||
use super::wall_type::Wall;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `wall`.
|
||||
///
|
||||
/// Obtain a handle from the [`WallTableAccess::wall`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.wall()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.wall().on_insert(...)`.
|
||||
pub struct WallTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Wall>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `wall`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait WallTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`WallTableHandle`], which mediates access to the table `wall`.
|
||||
fn wall(&self) -> WallTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl WallTableAccess for super::RemoteTables {
|
||||
fn wall(&self) -> WallTableHandle<'_> {
|
||||
WallTableHandle {
|
||||
imp: self.imp.get_table::<Wall>("wall"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WallInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct WallDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for WallTableHandle<'ctx> {
|
||||
type Row = Wall;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Wall> + '_ {
|
||||
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::<Wall>("wall");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.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<Wall>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Wall>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Access to the `id` unique index on the table `wall`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`WallIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.wall().id().find(...)`.
|
||||
pub struct WallIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Wall, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> WallTableHandle<'ctx> {
|
||||
/// Get a handle on the `id` unique index on the table `wall`.
|
||||
pub fn id(&self) -> WallIdUnique<'ctx> {
|
||||
WallIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> WallIdUnique<'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<Wall> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
18
jong/src/stdb/wall_type.rs
Normal file
18
jong/src/stdb/wall_type.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::tile_type::Tile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Wall {
|
||||
pub id: u32,
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Wall {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
22
jong/src/stdb/wind_type.rs
Normal file
22
jong/src/stdb/wind_type.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// 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)]
|
||||
#[derive(Copy, Eq, Hash)]
|
||||
pub enum Wind {
|
||||
Ton,
|
||||
|
||||
Nan,
|
||||
|
||||
Shaa,
|
||||
|
||||
Pei,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Wind {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue