re-organize crates
This commit is contained in:
parent
1afb7f4e3d
commit
c709fb5851
50 changed files with 148 additions and 121 deletions
10
jong-db/Cargo.toml
Normal file
10
jong-db/Cargo.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "jong-db"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
|
||||
[dependencies]
|
||||
jong-types.workspace = true
|
||||
spacetimedb-sdk.workspace = true
|
||||
104
jong-db/src/db/add_bot_reducer.rs
Normal file
104
jong-db/src/db/add_bot_reducer.rs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
// 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 AddBotArgs {
|
||||
pub lobby_id: u32,
|
||||
}
|
||||
|
||||
impl From<AddBotArgs> for super::Reducer {
|
||||
fn from(args: AddBotArgs) -> Self {
|
||||
Self::AddBot {
|
||||
lobby_id: args.lobby_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AddBotArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct AddBotCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `add_bot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait add_bot {
|
||||
/// Request that the remote module invoke the reducer `add_bot` 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_bot`] callbacks.
|
||||
fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`]
|
||||
/// to cancel the callback.
|
||||
fn on_add_bot(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> AddBotCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_add_bot`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_add_bot(&self, callback: AddBotCallbackId);
|
||||
}
|
||||
|
||||
impl add_bot for super::RemoteReducers {
|
||||
fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("add_bot", AddBotArgs { lobby_id })
|
||||
}
|
||||
fn on_add_bot(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> AddBotCallbackId {
|
||||
AddBotCallbackId(self.imp.on_reducer(
|
||||
"add_bot",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::AddBot { lobby_id },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, lobby_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_add_bot(&self, callback: AddBotCallbackId) {
|
||||
self.imp.remove_on_reducer("add_bot", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `add_bot`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_add_bot {
|
||||
/// Set the call-reducer flags for the reducer `add_bot` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn add_bot(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_add_bot for super::SetReducerFlags {
|
||||
fn add_bot(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("add_bot", flags);
|
||||
}
|
||||
}
|
||||
143
jong-db/src/db/bot_table.rs
Normal file
143
jong-db/src/db/bot_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::bot_type::Bot;
|
||||
use super::db_tile_type::DbTile;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `bot`.
|
||||
///
|
||||
/// Obtain a handle from the [`BotTableAccess::bot`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.bot()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.bot().on_insert(...)`.
|
||||
pub struct BotTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<Bot>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `bot`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait BotTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`BotTableHandle`], which mediates access to the table `bot`.
|
||||
fn bot(&self) -> BotTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl BotTableAccess for super::RemoteTables {
|
||||
fn bot(&self) -> BotTableHandle<'_> {
|
||||
BotTableHandle {
|
||||
imp: self.imp.get_table::<Bot>("bot"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BotInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct BotDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for BotTableHandle<'ctx> {
|
||||
type Row = Bot;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = Bot> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = BotInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BotInsertCallbackId {
|
||||
BotInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: BotInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = BotDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> BotDeleteCallbackId {
|
||||
BotDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: BotDeleteCallbackId) {
|
||||
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::<Bot>("bot");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct BotUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for BotTableHandle<'ctx> {
|
||||
type UpdateCallbackId = BotUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> BotUpdateCallbackId {
|
||||
BotUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: BotUpdateCallbackId) {
|
||||
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<Bot>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<Bot>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Access to the `id` unique index on the table `bot`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`BotIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.bot().id().find(...)`.
|
||||
pub struct BotIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Bot, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> BotTableHandle<'ctx> {
|
||||
/// Get a handle on the `id` unique index on the table `bot`.
|
||||
pub fn id(&self) -> BotIdUnique<'ctx> {
|
||||
BotIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> BotIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<Bot> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
21
jong-db/src/db/bot_type.rs
Normal file
21
jong-db/src/db/bot_type.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// 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::db_tile_type::DbTile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Bot {
|
||||
pub id: u32,
|
||||
pub lobby_id: u32,
|
||||
pub hand: Vec<DbTile>,
|
||||
pub pond: Vec<DbTile>,
|
||||
pub drawn_tile: Option<DbTile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Bot {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
100
jong-db/src/db/clear_all_reducer.rs
Normal file
100
jong-db/src/db/clear_all_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 ClearAllArgs {}
|
||||
|
||||
impl From<ClearAllArgs> for super::Reducer {
|
||||
fn from(args: ClearAllArgs) -> Self {
|
||||
Self::ClearAll
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ClearAllArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct ClearAllCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `clear_all`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait clear_all {
|
||||
/// Request that the remote module invoke the reducer `clear_all` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_clear_all`] callbacks.
|
||||
fn clear_all(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `clear_all`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`ClearAllCallbackId`] can be passed to [`Self::remove_on_clear_all`]
|
||||
/// to cancel the callback.
|
||||
fn on_clear_all(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> ClearAllCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_clear_all`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_clear_all(&self, callback: ClearAllCallbackId);
|
||||
}
|
||||
|
||||
impl clear_all for super::RemoteReducers {
|
||||
fn clear_all(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("clear_all", ClearAllArgs {})
|
||||
}
|
||||
fn on_clear_all(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> ClearAllCallbackId {
|
||||
ClearAllCallbackId(self.imp.on_reducer(
|
||||
"clear_all",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::ClearAll {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_clear_all(&self, callback: ClearAllCallbackId) {
|
||||
self.imp.remove_on_reducer("clear_all", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `clear_all`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_clear_all {
|
||||
/// Set the call-reducer flags for the reducer `clear_all` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn clear_all(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_clear_all for super::SetReducerFlags {
|
||||
fn clear_all(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("clear_all", flags);
|
||||
}
|
||||
}
|
||||
18
jong-db/src/db/db_tile_type.rs
Normal file
18
jong-db/src/db/db_tile_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 DbTile {
|
||||
pub id: u32,
|
||||
pub tile: Tile,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DbTile {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
18
jong-db/src/db/db_wall_type.rs
Normal file
18
jong-db/src/db/db_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::db_tile_type::DbTile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct DbWall {
|
||||
pub lobby_id: u32,
|
||||
pub tiles: Vec<DbTile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DbWall {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
105
jong-db/src/db/discard_tile_reducer.rs
Normal file
105
jong-db/src/db/discard_tile_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 DiscardTileArgs {
|
||||
pub tile_id: u32,
|
||||
}
|
||||
|
||||
impl From<DiscardTileArgs> for super::Reducer {
|
||||
fn from(args: DiscardTileArgs) -> Self {
|
||||
Self::DiscardTile {
|
||||
tile_id: args.tile_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DiscardTileArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct DiscardTileCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `discard_tile`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait discard_tile {
|
||||
/// Request that the remote module invoke the reducer `discard_tile` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_discard_tile`] callbacks.
|
||||
fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `discard_tile`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`DiscardTileCallbackId`] can be passed to [`Self::remove_on_discard_tile`]
|
||||
/// to cancel the callback.
|
||||
fn on_discard_tile(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> DiscardTileCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_discard_tile`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId);
|
||||
}
|
||||
|
||||
impl discard_tile for super::RemoteReducers {
|
||||
fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("discard_tile", DiscardTileArgs { tile_id })
|
||||
}
|
||||
fn on_discard_tile(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> DiscardTileCallbackId {
|
||||
DiscardTileCallbackId(self.imp.on_reducer(
|
||||
"discard_tile",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::DiscardTile { tile_id },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, tile_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId) {
|
||||
self.imp.remove_on_reducer("discard_tile", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `discard_tile`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_discard_tile {
|
||||
/// Set the call-reducer flags for the reducer `discard_tile` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn discard_tile(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_discard_tile for super::SetReducerFlags {
|
||||
fn discard_tile(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("discard_tile", flags);
|
||||
}
|
||||
}
|
||||
20
jong-db/src/db/dragon_type.rs
Normal file
20
jong-db/src/db/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;
|
||||
}
|
||||
100
jong-db/src/db/draw_tile_reducer.rs
Normal file
100
jong-db/src/db/draw_tile_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 DrawTileArgs {}
|
||||
|
||||
impl From<DrawTileArgs> for super::Reducer {
|
||||
fn from(args: DrawTileArgs) -> Self {
|
||||
Self::DrawTile
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for DrawTileArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct DrawTileCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `draw_tile`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait draw_tile {
|
||||
/// Request that the remote module invoke the reducer `draw_tile` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_draw_tile`] callbacks.
|
||||
fn draw_tile(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `draw_tile`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`DrawTileCallbackId`] can be passed to [`Self::remove_on_draw_tile`]
|
||||
/// to cancel the callback.
|
||||
fn on_draw_tile(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> DrawTileCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_draw_tile`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_draw_tile(&self, callback: DrawTileCallbackId);
|
||||
}
|
||||
|
||||
impl draw_tile for super::RemoteReducers {
|
||||
fn draw_tile(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("draw_tile", DrawTileArgs {})
|
||||
}
|
||||
fn on_draw_tile(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> DrawTileCallbackId {
|
||||
DrawTileCallbackId(self.imp.on_reducer(
|
||||
"draw_tile",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::DrawTile {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_draw_tile(&self, callback: DrawTileCallbackId) {
|
||||
self.imp.remove_on_reducer("draw_tile", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `draw_tile`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_draw_tile {
|
||||
/// Set the call-reducer flags for the reducer `draw_tile` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn draw_tile(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_draw_tile for super::SetReducerFlags {
|
||||
fn draw_tile(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("draw_tile", flags);
|
||||
}
|
||||
}
|
||||
26
jong-db/src/db/game_state_type.rs
Normal file
26
jong-db/src/db/game_state_type.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
#[derive(Copy, Eq, Hash)]
|
||||
pub enum GameState {
|
||||
None,
|
||||
|
||||
Lobby,
|
||||
|
||||
Setup,
|
||||
|
||||
Deal,
|
||||
|
||||
Play,
|
||||
|
||||
Exit,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for GameState {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
107
jong-db/src/db/join_or_create_lobby_reducer.rs
Normal file
107
jong-db/src/db/join_or_create_lobby_reducer.rs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// 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_id: u32,
|
||||
}
|
||||
|
||||
impl From<JoinOrCreateLobbyArgs> for super::Reducer {
|
||||
fn from(args: JoinOrCreateLobbyArgs) -> Self {
|
||||
Self::JoinOrCreateLobby {
|
||||
lobby_id: args.lobby_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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_id: u32) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// 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, &u32) + Send + 'static,
|
||||
) -> JoinOrCreateLobbyCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId);
|
||||
}
|
||||
|
||||
impl join_or_create_lobby for super::RemoteReducers {
|
||||
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id })
|
||||
}
|
||||
fn on_join_or_create_lobby(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> JoinOrCreateLobbyCallbackId {
|
||||
JoinOrCreateLobbyCallbackId(self.imp.on_reducer(
|
||||
"join_or_create_lobby",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::JoinOrCreateLobby { lobby_id },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, lobby_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) {
|
||||
self.imp
|
||||
.remove_on_reducer("join_or_create_lobby", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[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);
|
||||
}
|
||||
}
|
||||
176
jong-db/src/db/lobby_table.rs
Normal file
176
jong-db/src/db/lobby_table.rs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
// 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::game_state_type::GameState;
|
||||
use super::lobby_type::Lobby;
|
||||
use super::player_or_bot_type::PlayerOrBot;
|
||||
use super::turn_state_type::TurnState;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// 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);
|
||||
_table.add_unique_constraint::<u32>("host_player_id", |row| &row.host_player_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)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `host_player_id` unique index on the table `lobby`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`LobbyHostPlayerIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.lobby().host_player_id().find(...)`.
|
||||
pub struct LobbyHostPlayerIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Lobby, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> LobbyTableHandle<'ctx> {
|
||||
/// Get a handle on the `host_player_id` unique index on the table `lobby`.
|
||||
pub fn host_player_id(&self) -> LobbyHostPlayerIdUnique<'ctx> {
|
||||
LobbyHostPlayerIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("host_player_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> LobbyHostPlayerIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `host_player_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<Lobby> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
25
jong-db/src/db/lobby_type.rs
Normal file
25
jong-db/src/db/lobby_type.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::game_state_type::GameState;
|
||||
use super::player_or_bot_type::PlayerOrBot;
|
||||
use super::turn_state_type::TurnState;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Lobby {
|
||||
pub id: u32,
|
||||
pub host_player_id: u32,
|
||||
pub players: Vec<PlayerOrBot>,
|
||||
pub dealer_idx: u8,
|
||||
pub current_idx: u8,
|
||||
pub game_state: GameState,
|
||||
pub turn_state: TurnState,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Lobby {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
103
jong-db/src/db/login_or_add_player_reducer.rs
Normal file
103
jong-db/src/db/login_or_add_player_reducer.rs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub(super) struct LoginOrAddPlayerArgs {}
|
||||
|
||||
impl From<LoginOrAddPlayerArgs> for super::Reducer {
|
||||
fn from(args: LoginOrAddPlayerArgs) -> Self {
|
||||
Self::LoginOrAddPlayer
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for LoginOrAddPlayerArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct LoginOrAddPlayerCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `login_or_add_player`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait login_or_add_player {
|
||||
/// Request that the remote module invoke the reducer `login_or_add_player` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_login_or_add_player`] callbacks.
|
||||
fn login_or_add_player(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `login_or_add_player`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`LoginOrAddPlayerCallbackId`] can be passed to [`Self::remove_on_login_or_add_player`]
|
||||
/// to cancel the callback.
|
||||
fn on_login_or_add_player(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> LoginOrAddPlayerCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_login_or_add_player`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_login_or_add_player(&self, callback: LoginOrAddPlayerCallbackId);
|
||||
}
|
||||
|
||||
impl login_or_add_player for super::RemoteReducers {
|
||||
fn login_or_add_player(&self) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("login_or_add_player", LoginOrAddPlayerArgs {})
|
||||
}
|
||||
fn on_login_or_add_player(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> LoginOrAddPlayerCallbackId {
|
||||
LoginOrAddPlayerCallbackId(self.imp.on_reducer(
|
||||
"login_or_add_player",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::LoginOrAddPlayer {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_login_or_add_player(&self, callback: LoginOrAddPlayerCallbackId) {
|
||||
self.imp
|
||||
.remove_on_reducer("login_or_add_player", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `login_or_add_player`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_login_or_add_player {
|
||||
/// Set the call-reducer flags for the reducer `login_or_add_player` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn login_or_add_player(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_login_or_add_player for super::SetReducerFlags {
|
||||
fn login_or_add_player(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp
|
||||
.set_call_reducer_flags("login_or_add_player", flags);
|
||||
}
|
||||
}
|
||||
1018
jong-db/src/db/mod.rs
Normal file
1018
jong-db/src/db/mod.rs
Normal file
File diff suppressed because it is too large
Load diff
17
jong-db/src/db/player_or_bot_type.rs
Normal file
17
jong-db/src/db/player_or_bot_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 enum PlayerOrBot {
|
||||
Player(u32),
|
||||
|
||||
Bot(u32),
|
||||
}
|
||||
|
||||
impl __sdk::InModule for PlayerOrBot {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
176
jong-db/src/db/player_table.rs
Normal file
176
jong-db/src/db/player_table.rs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use super::db_tile_type::DbTile;
|
||||
use super::player_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);
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
/// Access to the `id` unique index on the table `player`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`PlayerIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.player().id().find(...)`.
|
||||
pub struct PlayerIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<Player, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> PlayerTableHandle<'ctx> {
|
||||
/// Get a handle on the `id` unique index on the table `player`.
|
||||
pub fn id(&self) -> PlayerIdUnique<'ctx> {
|
||||
PlayerIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> PlayerIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<Player> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
25
jong-db/src/db/player_type.rs
Normal file
25
jong-db/src/db/player_type.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
use super::db_tile_type::DbTile;
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
pub struct Player {
|
||||
pub identity: __sdk::Identity,
|
||||
pub id: u32,
|
||||
pub name: Option<String>,
|
||||
pub lobby_id: u32,
|
||||
pub ready: bool,
|
||||
pub sort: bool,
|
||||
pub hand: Vec<DbTile>,
|
||||
pub pond: Vec<DbTile>,
|
||||
pub drawn_tile: Option<DbTile>,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for Player {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
15
jong-db/src/db/rank_type.rs
Normal file
15
jong-db/src/db/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-db/src/db/set_ready_reducer.rs
Normal file
102
jong-db/src/db/set_ready_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 SetReadyArgs {
|
||||
pub ready: bool,
|
||||
}
|
||||
|
||||
impl From<SetReadyArgs> for super::Reducer {
|
||||
fn from(args: SetReadyArgs) -> Self {
|
||||
Self::SetReady { ready: args.ready }
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SetReadyArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct SetReadyCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `set_ready`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait set_ready {
|
||||
/// Request that the remote module invoke the reducer `set_ready` 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_ready`] callbacks.
|
||||
fn set_ready(&self, ready: bool) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`]
|
||||
/// to cancel the callback.
|
||||
fn on_set_ready(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static,
|
||||
) -> SetReadyCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_set_ready`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_set_ready(&self, callback: SetReadyCallbackId);
|
||||
}
|
||||
|
||||
impl set_ready for super::RemoteReducers {
|
||||
fn set_ready(&self, ready: bool) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("set_ready", SetReadyArgs { ready })
|
||||
}
|
||||
fn on_set_ready(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static,
|
||||
) -> SetReadyCallbackId {
|
||||
SetReadyCallbackId(self.imp.on_reducer(
|
||||
"set_ready",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::SetReady { ready },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, ready)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_set_ready(&self, callback: SetReadyCallbackId) {
|
||||
self.imp.remove_on_reducer("set_ready", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `set_ready`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_set_ready {
|
||||
/// Set the call-reducer flags for the reducer `set_ready` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn set_ready(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_set_ready for super::SetReducerFlags {
|
||||
fn set_ready(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("set_ready", flags);
|
||||
}
|
||||
}
|
||||
105
jong-db/src/db/shuffle_deal_reducer.rs
Normal file
105
jong-db/src/db/shuffle_deal_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 ShuffleDealArgs {
|
||||
pub lobby_id: u32,
|
||||
}
|
||||
|
||||
impl From<ShuffleDealArgs> for super::Reducer {
|
||||
fn from(args: ShuffleDealArgs) -> Self {
|
||||
Self::ShuffleDeal {
|
||||
lobby_id: args.lobby_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for ShuffleDealArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct ShuffleDealCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `shuffle_deal`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait shuffle_deal {
|
||||
/// Request that the remote module invoke the reducer `shuffle_deal` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_shuffle_deal`] callbacks.
|
||||
fn shuffle_deal(&self, lobby_id: u32) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `shuffle_deal`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`ShuffleDealCallbackId`] can be passed to [`Self::remove_on_shuffle_deal`]
|
||||
/// to cancel the callback.
|
||||
fn on_shuffle_deal(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> ShuffleDealCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_shuffle_deal`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_shuffle_deal(&self, callback: ShuffleDealCallbackId);
|
||||
}
|
||||
|
||||
impl shuffle_deal for super::RemoteReducers {
|
||||
fn shuffle_deal(&self, lobby_id: u32) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("shuffle_deal", ShuffleDealArgs { lobby_id })
|
||||
}
|
||||
fn on_shuffle_deal(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
|
||||
) -> ShuffleDealCallbackId {
|
||||
ShuffleDealCallbackId(self.imp.on_reducer(
|
||||
"shuffle_deal",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::ShuffleDeal { lobby_id },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, lobby_id)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_shuffle_deal(&self, callback: ShuffleDealCallbackId) {
|
||||
self.imp.remove_on_reducer("shuffle_deal", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `shuffle_deal`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_shuffle_deal {
|
||||
/// Set the call-reducer flags for the reducer `shuffle_deal` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn shuffle_deal(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_shuffle_deal for super::SetReducerFlags {
|
||||
fn shuffle_deal(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("shuffle_deal", flags);
|
||||
}
|
||||
}
|
||||
100
jong-db/src/db/skip_call_reducer.rs
Normal file
100
jong-db/src/db/skip_call_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 SkipCallArgs {}
|
||||
|
||||
impl From<SkipCallArgs> for super::Reducer {
|
||||
fn from(args: SkipCallArgs) -> Self {
|
||||
Self::SkipCall
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for SkipCallArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct SkipCallCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `skip_call`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait skip_call {
|
||||
/// Request that the remote module invoke the reducer `skip_call` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_skip_call`] callbacks.
|
||||
fn skip_call(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `skip_call`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`SkipCallCallbackId`] can be passed to [`Self::remove_on_skip_call`]
|
||||
/// to cancel the callback.
|
||||
fn on_skip_call(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> SkipCallCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_skip_call`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_skip_call(&self, callback: SkipCallCallbackId);
|
||||
}
|
||||
|
||||
impl skip_call for super::RemoteReducers {
|
||||
fn skip_call(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("skip_call", SkipCallArgs {})
|
||||
}
|
||||
fn on_skip_call(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> SkipCallCallbackId {
|
||||
SkipCallCallbackId(self.imp.on_reducer(
|
||||
"skip_call",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::SkipCall {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_skip_call(&self, callback: SkipCallCallbackId) {
|
||||
self.imp.remove_on_reducer("skip_call", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `skip_call`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_skip_call {
|
||||
/// Set the call-reducer flags for the reducer `skip_call` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn skip_call(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_skip_call for super::SetReducerFlags {
|
||||
fn skip_call(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("skip_call", flags);
|
||||
}
|
||||
}
|
||||
100
jong-db/src/db/start_game_reducer.rs
Normal file
100
jong-db/src/db/start_game_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 StartGameArgs {}
|
||||
|
||||
impl From<StartGameArgs> for super::Reducer {
|
||||
fn from(args: StartGameArgs) -> Self {
|
||||
Self::StartGame
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for StartGameArgs {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct StartGameCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `start_game`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteReducers`].
|
||||
pub trait start_game {
|
||||
/// Request that the remote module invoke the reducer `start_game` to run as soon as possible.
|
||||
///
|
||||
/// This method returns immediately, and errors only if we are unable to send the request.
|
||||
/// The reducer will run asynchronously in the future,
|
||||
/// and its status can be observed by listening for [`Self::on_start_game`] callbacks.
|
||||
fn start_game(&self) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `start_game`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`StartGameCallbackId`] can be passed to [`Self::remove_on_start_game`]
|
||||
/// to cancel the callback.
|
||||
fn on_start_game(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> StartGameCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_start_game`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_start_game(&self, callback: StartGameCallbackId);
|
||||
}
|
||||
|
||||
impl start_game for super::RemoteReducers {
|
||||
fn start_game(&self) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("start_game", StartGameArgs {})
|
||||
}
|
||||
fn on_start_game(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
|
||||
) -> StartGameCallbackId {
|
||||
StartGameCallbackId(self.imp.on_reducer(
|
||||
"start_game",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::StartGame {},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_start_game(&self, callback: StartGameCallbackId) {
|
||||
self.imp.remove_on_reducer("start_game", callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `start_game`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_start_game {
|
||||
/// Set the call-reducer flags for the reducer `start_game` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn start_game(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_start_game for super::SetReducerFlags {
|
||||
fn start_game(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("start_game", flags);
|
||||
}
|
||||
}
|
||||
27
jong-db/src/db/suit_type.rs
Normal file
27
jong-db/src/db/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;
|
||||
}
|
||||
143
jong-db/src/db/tile_table.rs
Normal file
143
jong-db/src/db/tile_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::db_tile_type::DbTile;
|
||||
use super::tile_type::Tile;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `tile`.
|
||||
///
|
||||
/// Obtain a handle from the [`TileTableAccess::tile`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.tile()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.tile().on_insert(...)`.
|
||||
pub struct TileTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<DbTile>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `tile`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait TileTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`TileTableHandle`], which mediates access to the table `tile`.
|
||||
fn tile(&self) -> TileTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl TileTableAccess for super::RemoteTables {
|
||||
fn tile(&self) -> TileTableHandle<'_> {
|
||||
TileTableHandle {
|
||||
imp: self.imp.get_table::<DbTile>("tile"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TileInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct TileDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for TileTableHandle<'ctx> {
|
||||
type Row = DbTile;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = DbTile> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = TileInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> TileInsertCallbackId {
|
||||
TileInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: TileInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = TileDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> TileDeleteCallbackId {
|
||||
TileDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: TileDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<DbTile>("tile");
|
||||
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
||||
}
|
||||
pub struct TileUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for TileTableHandle<'ctx> {
|
||||
type UpdateCallbackId = TileUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> TileUpdateCallbackId {
|
||||
TileUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: TileUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<DbTile>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<DbTile>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Access to the `id` unique index on the table `tile`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`TileIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.tile().id().find(...)`.
|
||||
pub struct TileIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<DbTile, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> TileTableHandle<'ctx> {
|
||||
/// Get a handle on the `id` unique index on the table `tile`.
|
||||
pub fn id(&self) -> TileIdUnique<'ctx> {
|
||||
TileIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> TileIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<DbTile> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
17
jong-db/src/db/tile_type.rs
Normal file
17
jong-db/src/db/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;
|
||||
}
|
||||
26
jong-db/src/db/turn_state_type.rs
Normal file
26
jong-db/src/db/turn_state_type.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
|
||||
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
|
||||
|
||||
#![allow(unused, clippy::all)]
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
|
||||
#[sats(crate = __lib)]
|
||||
#[derive(Copy, Eq, Hash)]
|
||||
pub enum TurnState {
|
||||
None,
|
||||
|
||||
Tsumo,
|
||||
|
||||
Menzen,
|
||||
|
||||
RiichiKan,
|
||||
|
||||
RonChiiPonKan,
|
||||
|
||||
End,
|
||||
}
|
||||
|
||||
impl __sdk::InModule for TurnState {
|
||||
type Module = super::RemoteModule;
|
||||
}
|
||||
143
jong-db/src/db/wall_table.rs
Normal file
143
jong-db/src/db/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::db_tile_type::DbTile;
|
||||
use super::db_wall_type::DbWall;
|
||||
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `wall`.
|
||||
///
|
||||
/// Obtain a handle from the [`WallTableAccess::wall`] method on [`super::RemoteTables`],
|
||||
/// like `ctx.db.wall()`.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.wall().on_insert(...)`.
|
||||
pub struct WallTableHandle<'ctx> {
|
||||
imp: __sdk::TableHandle<DbWall>,
|
||||
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the table `wall`.
|
||||
///
|
||||
/// Implemented for [`super::RemoteTables`].
|
||||
pub trait WallTableAccess {
|
||||
#[allow(non_snake_case)]
|
||||
/// Obtain a [`WallTableHandle`], which mediates access to the table `wall`.
|
||||
fn wall(&self) -> WallTableHandle<'_>;
|
||||
}
|
||||
|
||||
impl WallTableAccess for super::RemoteTables {
|
||||
fn wall(&self) -> WallTableHandle<'_> {
|
||||
WallTableHandle {
|
||||
imp: self.imp.get_table::<DbWall>("wall"),
|
||||
ctx: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WallInsertCallbackId(__sdk::CallbackId);
|
||||
pub struct WallDeleteCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::Table for WallTableHandle<'ctx> {
|
||||
type Row = DbWall;
|
||||
type EventContext = super::EventContext;
|
||||
|
||||
fn count(&self) -> u64 {
|
||||
self.imp.count()
|
||||
}
|
||||
fn iter(&self) -> impl Iterator<Item = DbWall> + '_ {
|
||||
self.imp.iter()
|
||||
}
|
||||
|
||||
type InsertCallbackId = WallInsertCallbackId;
|
||||
|
||||
fn on_insert(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> WallInsertCallbackId {
|
||||
WallInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_insert(&self, callback: WallInsertCallbackId) {
|
||||
self.imp.remove_on_insert(callback.0)
|
||||
}
|
||||
|
||||
type DeleteCallbackId = WallDeleteCallbackId;
|
||||
|
||||
fn on_delete(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
||||
) -> WallDeleteCallbackId {
|
||||
WallDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_delete(&self, callback: WallDeleteCallbackId) {
|
||||
self.imp.remove_on_delete(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
||||
let _table = client_cache.get_or_make_table::<DbWall>("wall");
|
||||
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
|
||||
}
|
||||
pub struct WallUpdateCallbackId(__sdk::CallbackId);
|
||||
|
||||
impl<'ctx> __sdk::TableWithPrimaryKey for WallTableHandle<'ctx> {
|
||||
type UpdateCallbackId = WallUpdateCallbackId;
|
||||
|
||||
fn on_update(
|
||||
&self,
|
||||
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
||||
) -> WallUpdateCallbackId {
|
||||
WallUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
||||
}
|
||||
|
||||
fn remove_on_update(&self, callback: WallUpdateCallbackId) {
|
||||
self.imp.remove_on_update(callback.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub(super) fn parse_table_update(
|
||||
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
|
||||
) -> __sdk::Result<__sdk::TableUpdate<DbWall>> {
|
||||
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
|
||||
__sdk::InternalError::failed_parse("TableUpdate<DbWall>", "TableUpdate")
|
||||
.with_cause(e)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Access to the `lobby_id` unique index on the table `wall`,
|
||||
/// which allows point queries on the field of the same name
|
||||
/// via the [`WallLobbyIdUnique::find`] method.
|
||||
///
|
||||
/// Users are encouraged not to explicitly reference this type,
|
||||
/// but to directly chain method calls,
|
||||
/// like `ctx.db.wall().lobby_id().find(...)`.
|
||||
pub struct WallLobbyIdUnique<'ctx> {
|
||||
imp: __sdk::UniqueConstraintHandle<DbWall, u32>,
|
||||
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
||||
}
|
||||
|
||||
impl<'ctx> WallTableHandle<'ctx> {
|
||||
/// Get a handle on the `lobby_id` unique index on the table `wall`.
|
||||
pub fn lobby_id(&self) -> WallLobbyIdUnique<'ctx> {
|
||||
WallLobbyIdUnique {
|
||||
imp: self.imp.get_unique_constraint::<u32>("lobby_id"),
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ctx> WallLobbyIdUnique<'ctx> {
|
||||
/// Find the subscribed row whose `lobby_id` column value is equal to `col_val`,
|
||||
/// if such a row is present in the client cache.
|
||||
pub fn find(&self, col_val: &u32) -> Option<DbWall> {
|
||||
self.imp.find(col_val)
|
||||
}
|
||||
}
|
||||
22
jong-db/src/db/wind_type.rs
Normal file
22
jong-db/src/db/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;
|
||||
}
|
||||
54
jong-db/src/lib.rs
Normal file
54
jong-db/src/lib.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
pub mod db;
|
||||
pub use db::*;
|
||||
|
||||
impl From<GameState> for jong_types::GameState {
|
||||
fn from(value: GameState) -> Self {
|
||||
Self::from_repr(value as usize).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TurnState> for jong_types::TurnState {
|
||||
fn from(value: TurnState) -> Self {
|
||||
Self::from_repr(value as usize).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Tile> for jong_types::Tile {
|
||||
fn from(value: &tile_type::Tile) -> Self {
|
||||
Self {
|
||||
suit: value.suit.clone().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Suit> for jong_types::Suit {
|
||||
fn from(value: Suit) -> Self {
|
||||
match value {
|
||||
Suit::Man(rank) => Self::Man(rank.into()),
|
||||
Suit::Pin(rank) => Self::Pin(rank.into()),
|
||||
Suit::Sou(rank) => Self::Sou(rank.into()),
|
||||
Suit::Wind(wind) => Self::Wind(wind.into()),
|
||||
Suit::Dragon(dragon) => Self::Dragon(dragon.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Rank> for jong_types::Rank {
|
||||
fn from(value: Rank) -> Self {
|
||||
Self {
|
||||
number: value.number,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Wind> for jong_types::Wind {
|
||||
fn from(value: Wind) -> Self {
|
||||
Self::from_repr(value as usize).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Dragon> for jong_types::Dragon {
|
||||
fn from(value: Dragon) -> Self {
|
||||
Self::from_repr(value as usize).unwrap()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue