This commit is contained in:
Tao Tien 2026-02-22 00:08:02 -08:00
parent d1446309c4
commit d7b4221727
41 changed files with 893 additions and 1673 deletions

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -20,8 +14,8 @@ impl From<AddBotArgs> for super::Reducer {
fn from(args: AddBotArgs) -> Self {
Self::AddBot {
lobby_id: args.lobby_id,
}
}
}
}
}
impl __sdk::InModule for AddBotArgs {
@ -40,8 +34,7 @@ pub trait add_bot {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_add_bot`] callbacks.
fn add_bot(&self, lobby_id: u32,
) -> __sdk::Result<()>;
fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -49,35 +42,39 @@ pub trait add_bot {
///
/// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`]
/// to cancel the callback.
fn on_add_bot(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> AddBotCallbackId;
fn on_add_bot(
&self,
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> AddBotCallbackId;
/// Cancel a callback previously registered by [`Self::on_add_bot`],
/// causing it not to run in the future.
fn remove_on_add_bot(&self, callback: AddBotCallbackId);
}
impl add_bot for super::RemoteReducers {
fn add_bot(&self, lobby_id: u32,
) -> __sdk::Result<()> {
self.imp.call_reducer("add_bot", AddBotArgs { lobby_id, })
fn add_bot(&self, lobby_id: u32) -> __sdk::Result<()> {
self.imp.call_reducer("add_bot", AddBotArgs { lobby_id })
}
fn on_add_bot(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> AddBotCallbackId {
AddBotCallbackId(self.imp.on_reducer(
"add_bot",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::AddBot {
lobby_id,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::AddBot { lobby_id },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, lobby_id, )
} = ctx
else {
unreachable!()
};
callback(ctx, lobby_id)
}),
))
}
@ -105,4 +102,3 @@ impl set_flags_for_add_bot for super::SetReducerFlags {
self.imp.set_call_reducer_flags("add_bot", flags);
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::game_timer_type::GameTimer;
@ -21,8 +16,8 @@ impl From<AdvanceGameArgs> for super::Reducer {
fn from(args: AdvanceGameArgs) -> Self {
Self::AdvanceGame {
game_timer: args.game_timer,
}
}
}
}
}
impl __sdk::InModule for AdvanceGameArgs {
@ -41,8 +36,7 @@ pub trait advance_game {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_advance_game`] callbacks.
fn advance_game(&self, game_timer: GameTimer,
) -> __sdk::Result<()>;
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -50,35 +44,40 @@ pub trait advance_game {
///
/// The returned [`AdvanceGameCallbackId`] can be passed to [`Self::remove_on_advance_game`]
/// to cancel the callback.
fn on_advance_game(&self, callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static) -> AdvanceGameCallbackId;
fn on_advance_game(
&self,
callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static,
) -> AdvanceGameCallbackId;
/// Cancel a callback previously registered by [`Self::on_advance_game`],
/// causing it not to run in the future.
fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId);
}
impl advance_game for super::RemoteReducers {
fn advance_game(&self, game_timer: GameTimer,
) -> __sdk::Result<()> {
self.imp.call_reducer("advance_game", AdvanceGameArgs { game_timer, })
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> {
self.imp
.call_reducer("advance_game", AdvanceGameArgs { game_timer })
}
fn on_advance_game(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static,
) -> AdvanceGameCallbackId {
AdvanceGameCallbackId(self.imp.on_reducer(
"advance_game",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::AdvanceGame {
game_timer,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::AdvanceGame { game_timer },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, game_timer, )
} = ctx
else {
unreachable!()
};
callback(ctx, game_timer)
}),
))
}
@ -106,4 +105,3 @@ impl set_flags_for_advance_game for super::SetReducerFlags {
self.imp.set_call_reducer_flags("advance_game", flags);
}
}

View file

@ -1,144 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use super::advance_state_timer_type::AdvanceStateTimer;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `advance_state_timer`.
///
/// Obtain a handle from the [`AdvanceStateTimerTableAccess::advance_state_timer`] method on [`super::RemoteTables`],
/// like `ctx.db.advance_state_timer()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.advance_state_timer().on_insert(...)`.
pub struct AdvanceStateTimerTableHandle<'ctx> {
imp: __sdk::TableHandle<AdvanceStateTimer>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `advance_state_timer`.
///
/// Implemented for [`super::RemoteTables`].
pub trait AdvanceStateTimerTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`AdvanceStateTimerTableHandle`], which mediates access to the table `advance_state_timer`.
fn advance_state_timer(&self) -> AdvanceStateTimerTableHandle<'_>;
}
impl AdvanceStateTimerTableAccess for super::RemoteTables {
fn advance_state_timer(&self) -> AdvanceStateTimerTableHandle<'_> {
AdvanceStateTimerTableHandle {
imp: self
.imp
.get_table::<AdvanceStateTimer>("advance_state_timer"),
ctx: std::marker::PhantomData,
}
}
}
pub struct AdvanceStateTimerInsertCallbackId(__sdk::CallbackId);
pub struct AdvanceStateTimerDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for AdvanceStateTimerTableHandle<'ctx> {
type Row = AdvanceStateTimer;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = AdvanceStateTimer> + '_ {
self.imp.iter()
}
type InsertCallbackId = AdvanceStateTimerInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> AdvanceStateTimerInsertCallbackId {
AdvanceStateTimerInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: AdvanceStateTimerInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = AdvanceStateTimerDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> AdvanceStateTimerDeleteCallbackId {
AdvanceStateTimerDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: AdvanceStateTimerDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<AdvanceStateTimer>("advance_state_timer");
_table.add_unique_constraint::<u64>("scheduled_id", |row| &row.scheduled_id);
}
pub struct AdvanceStateTimerUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for AdvanceStateTimerTableHandle<'ctx> {
type UpdateCallbackId = AdvanceStateTimerUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> AdvanceStateTimerUpdateCallbackId {
AdvanceStateTimerUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: AdvanceStateTimerUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<AdvanceStateTimer>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<AdvanceStateTimer>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `scheduled_id` unique index on the table `advance_state_timer`,
/// which allows point queries on the field of the same name
/// via the [`AdvanceStateTimerScheduledIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.advance_state_timer().scheduled_id().find(...)`.
pub struct AdvanceStateTimerScheduledIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<AdvanceStateTimer, u64>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> AdvanceStateTimerTableHandle<'ctx> {
/// Get a handle on the `scheduled_id` unique index on the table `advance_state_timer`.
pub fn scheduled_id(&self) -> AdvanceStateTimerScheduledIdUnique<'ctx> {
AdvanceStateTimerScheduledIdUnique {
imp: self.imp.get_unique_constraint::<u64>("scheduled_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> AdvanceStateTimerScheduledIdUnique<'ctx> {
/// Find the subscribed row whose `scheduled_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u64) -> Option<AdvanceStateTimer> {
self.imp.find(col_val)
}
}

View file

@ -1,17 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct AdvanceStateTimer {
pub scheduled_id: u64,
pub scheduled_at: __sdk::ScheduleAt,
pub lobby_id: u32,
}
impl __sdk::InModule for AdvanceStateTimer {
type Module = super::RemoteModule;
}

View file

@ -2,15 +2,10 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::bot_type::Bot;
use super::turn_state_type::TurnState;
use super::db_tile_type::DbTile;
use super::turn_state_type::TurnState;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `bot`.
///
@ -51,8 +46,12 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> {
type Row = Bot;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = Bot> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = Bot> + '_ {
self.imp.iter()
}
type InsertCallbackId = BotInsertCallbackId;
@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for BotTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<Bot>("bot");
let _table = client_cache.get_or_make_table::<Bot>("bot");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
}
pub struct BotUpdateCallbackId(__sdk::CallbackId);
@ -104,46 +102,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for BotTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<Bot>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<Bot>",
"TableUpdate",
).with_cause(e).into()
__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>,
}
/// 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> 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)
}
}
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)
}
}

View file

@ -2,15 +2,10 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::turn_state_type::TurnState;
use super::db_tile_type::DbTile;
use super::turn_state_type::TurnState;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -18,13 +13,11 @@ pub struct Bot {
pub id: u32,
pub lobby_id: u32,
pub turn_state: TurnState,
pub hand: Vec::<DbTile>,
pub pond: Vec::<DbTile>,
pub working_tile: Option::<DbTile>,
pub hand: Vec<DbTile>,
pub pond: Vec<DbTile>,
pub working_tile: Option<DbTile>,
}
impl __sdk::InModule for Bot {
type Module = super::RemoteModule;
}

View file

@ -2,23 +2,16 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct ClearAllArgs {
}
pub(super) struct ClearAllArgs {}
impl From<ClearAllArgs> for super::Reducer {
fn from(args: ClearAllArgs) -> Self {
Self::ClearAll
}
}
}
impl __sdk::InModule for ClearAllArgs {
@ -37,7 +30,7 @@ pub trait clear_all {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_clear_all`] callbacks.
fn clear_all(&self, ) -> __sdk::Result<()>;
fn clear_all(&self) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `clear_all`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -45,34 +38,39 @@ pub trait clear_all {
///
/// The returned [`ClearAllCallbackId`] can be passed to [`Self::remove_on_clear_all`]
/// to cancel the callback.
fn on_clear_all(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ClearAllCallbackId;
fn on_clear_all(
&self,
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> ClearAllCallbackId;
/// Cancel a callback previously registered by [`Self::on_clear_all`],
/// causing it not to run in the future.
fn remove_on_clear_all(&self, callback: ClearAllCallbackId);
}
impl clear_all for super::RemoteReducers {
fn clear_all(&self, ) -> __sdk::Result<()> {
self.imp.call_reducer("clear_all", ClearAllArgs { })
fn clear_all(&self) -> __sdk::Result<()> {
self.imp.call_reducer("clear_all", ClearAllArgs {})
}
fn on_clear_all(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> ClearAllCallbackId {
ClearAllCallbackId(self.imp.on_reducer(
"clear_all",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::ClearAll {
event:
__sdk::ReducerEvent {
reducer: super::Reducer::ClearAll {},
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, )
} = ctx
else {
unreachable!()
};
callback(ctx)
}),
))
}
@ -100,4 +98,3 @@ impl set_flags_for_clear_all for super::SetReducerFlags {
self.imp.set_call_reducer_flags("clear_all", flags);
}
}

View file

@ -2,23 +2,16 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct ConnectArgs {
}
pub(super) struct ConnectArgs {}
impl From<ConnectArgs> for super::Reducer {
fn from(args: ConnectArgs) -> Self {
Self::Connect
}
}
}
impl __sdk::InModule for ConnectArgs {
@ -37,7 +30,7 @@ pub trait connect {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_connect`] callbacks.
fn connect(&self, ) -> __sdk::Result<()>;
fn connect(&self) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `connect`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -45,34 +38,39 @@ pub trait connect {
///
/// The returned [`ConnectCallbackId`] can be passed to [`Self::remove_on_connect`]
/// to cancel the callback.
fn on_connect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> ConnectCallbackId;
fn on_connect(
&self,
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> ConnectCallbackId;
/// Cancel a callback previously registered by [`Self::on_connect`],
/// causing it not to run in the future.
fn remove_on_connect(&self, callback: ConnectCallbackId);
}
impl connect for super::RemoteReducers {
fn connect(&self, ) -> __sdk::Result<()> {
self.imp.call_reducer("connect", ConnectArgs { })
fn connect(&self) -> __sdk::Result<()> {
self.imp.call_reducer("connect", ConnectArgs {})
}
fn on_connect(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> ConnectCallbackId {
ConnectCallbackId(self.imp.on_reducer(
"connect",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::Connect {
event:
__sdk::ReducerEvent {
reducer: super::Reducer::Connect {},
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, )
} = ctx
else {
unreachable!()
};
callback(ctx)
}),
))
}
@ -100,4 +98,3 @@ impl set_flags_for_connect for super::SetReducerFlags {
self.imp.set_call_reducer_flags("connect", flags);
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::tile_type::Tile;
@ -18,8 +13,6 @@ pub struct DbTile {
pub tile: Tile,
}
impl __sdk::InModule for DbTile {
type Module = super::RemoteModule;
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::db_tile_type::DbTile;
@ -15,11 +10,9 @@ use super::db_tile_type::DbTile;
#[sats(crate = __lib)]
pub struct DbWall {
pub lobby_id: u32,
pub tiles: Vec::<DbTile>,
pub tiles: Vec<DbTile>,
}
impl __sdk::InModule for DbWall {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -20,8 +14,8 @@ impl From<DiscardTileArgs> for super::Reducer {
fn from(args: DiscardTileArgs) -> Self {
Self::DiscardTile {
tile_id: args.tile_id,
}
}
}
}
}
impl __sdk::InModule for DiscardTileArgs {
@ -40,8 +34,7 @@ pub trait discard_tile {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_discard_tile`] callbacks.
fn discard_tile(&self, tile_id: u32,
) -> __sdk::Result<()>;
fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `discard_tile`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -49,35 +42,40 @@ pub trait discard_tile {
///
/// The returned [`DiscardTileCallbackId`] can be passed to [`Self::remove_on_discard_tile`]
/// to cancel the callback.
fn on_discard_tile(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> DiscardTileCallbackId;
fn on_discard_tile(
&self,
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> DiscardTileCallbackId;
/// Cancel a callback previously registered by [`Self::on_discard_tile`],
/// causing it not to run in the future.
fn remove_on_discard_tile(&self, callback: DiscardTileCallbackId);
}
impl discard_tile for super::RemoteReducers {
fn discard_tile(&self, tile_id: u32,
) -> __sdk::Result<()> {
self.imp.call_reducer("discard_tile", DiscardTileArgs { tile_id, })
fn discard_tile(&self, tile_id: u32) -> __sdk::Result<()> {
self.imp
.call_reducer("discard_tile", DiscardTileArgs { tile_id })
}
fn on_discard_tile(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> DiscardTileCallbackId {
DiscardTileCallbackId(self.imp.on_reducer(
"discard_tile",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::DiscardTile {
tile_id,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::DiscardTile { tile_id },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, tile_id, )
} = ctx
else {
unreachable!()
};
callback(ctx, tile_id)
}),
))
}
@ -105,4 +103,3 @@ impl set_flags_for_discard_tile for super::SetReducerFlags {
self.imp.set_call_reducer_flags("discard_tile", flags);
}
}

View file

@ -2,23 +2,16 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct DisconnectArgs {
}
pub(super) struct DisconnectArgs {}
impl From<DisconnectArgs> for super::Reducer {
fn from(args: DisconnectArgs) -> Self {
Self::Disconnect
}
}
}
impl __sdk::InModule for DisconnectArgs {
@ -37,7 +30,7 @@ pub trait disconnect {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_disconnect`] callbacks.
fn disconnect(&self, ) -> __sdk::Result<()>;
fn disconnect(&self) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `disconnect`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -45,34 +38,39 @@ pub trait disconnect {
///
/// The returned [`DisconnectCallbackId`] can be passed to [`Self::remove_on_disconnect`]
/// to cancel the callback.
fn on_disconnect(&self, callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static) -> DisconnectCallbackId;
fn on_disconnect(
&self,
callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> DisconnectCallbackId;
/// Cancel a callback previously registered by [`Self::on_disconnect`],
/// causing it not to run in the future.
fn remove_on_disconnect(&self, callback: DisconnectCallbackId);
}
impl disconnect for super::RemoteReducers {
fn disconnect(&self, ) -> __sdk::Result<()> {
self.imp.call_reducer("disconnect", DisconnectArgs { })
fn disconnect(&self) -> __sdk::Result<()> {
self.imp.call_reducer("disconnect", DisconnectArgs {})
}
fn on_disconnect(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext) + Send + 'static,
) -> DisconnectCallbackId {
DisconnectCallbackId(self.imp.on_reducer(
"disconnect",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::Disconnect {
event:
__sdk::ReducerEvent {
reducer: super::Reducer::Disconnect {},
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, )
} = ctx
else {
unreachable!()
};
callback(ctx)
}),
))
}
@ -100,4 +98,3 @@ impl set_flags_for_disconnect for super::SetReducerFlags {
self.imp.set_call_reducer_flags("disconnect", flags);
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -18,12 +13,8 @@ pub enum Dragon {
Hatsu,
Chun,
}
impl __sdk::InModule for Dragon {
type Module = super::RemoteModule;
}

View file

@ -1,100 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct DrawTileArgs {}
impl From<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);
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -24,12 +19,8 @@ pub enum GameState {
Play,
Exit,
}
impl __sdk::InModule for GameState {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,8 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::game_timer_type::GameTimer;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `game_timer`.
///
@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> {
type Row = GameTimer;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = GameTimer> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = GameTimer> + '_ {
self.imp.iter()
}
type InsertCallbackId = GameTimerInsertCallbackId;
@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<GameTimer>("game_timer");
let _table = client_cache.get_or_make_table::<GameTimer>("game_timer");
_table.add_unique_constraint::<u64>("id", |row| &row.id);
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
}
@ -103,76 +101,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<GameTimer>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<GameTimer>",
"TableUpdate",
).with_cause(e).into()
__sdk::InternalError::failed_parse("TableUpdate<GameTimer>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `id` unique index on the table `game_timer`,
/// which allows point queries on the field of the same name
/// via the [`GameTimerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.game_timer().id().find(...)`.
pub struct GameTimerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<GameTimer, u64>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
/// Access to the `id` unique index on the table `game_timer`,
/// which allows point queries on the field of the same name
/// via the [`GameTimerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.game_timer().id().find(...)`.
pub struct GameTimerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<GameTimer, u64>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> GameTimerTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `game_timer`.
pub fn id(&self) -> GameTimerIdUnique<'ctx> {
GameTimerIdUnique {
imp: self.imp.get_unique_constraint::<u64>("id"),
phantom: std::marker::PhantomData,
}
}
impl<'ctx> GameTimerTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `game_timer`.
pub fn id(&self) -> GameTimerIdUnique<'ctx> {
GameTimerIdUnique {
imp: self.imp.get_unique_constraint::<u64>("id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> GameTimerIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u64) -> Option<GameTimer> {
self.imp.find(col_val)
}
}
/// Access to the `lobby_id` unique index on the table `game_timer`,
/// which allows point queries on the field of the same name
/// via the [`GameTimerLobbyIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.game_timer().lobby_id().find(...)`.
pub struct GameTimerLobbyIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<GameTimer, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> GameTimerIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u64) -> Option<GameTimer> {
self.imp.find(col_val)
}
}
impl<'ctx> GameTimerTableHandle<'ctx> {
/// Get a handle on the `lobby_id` unique index on the table `game_timer`.
pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> {
GameTimerLobbyIdUnique {
imp: self.imp.get_unique_constraint::<u32>("lobby_id"),
phantom: std::marker::PhantomData,
}
}
}
/// Access to the `lobby_id` unique index on the table `game_timer`,
/// which allows point queries on the field of the same name
/// via the [`GameTimerLobbyIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.game_timer().lobby_id().find(...)`.
pub struct GameTimerLobbyIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<GameTimer, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> GameTimerLobbyIdUnique<'ctx> {
/// Find the subscribed row whose `lobby_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<GameTimer> {
self.imp.find(col_val)
}
impl<'ctx> GameTimerTableHandle<'ctx> {
/// Get a handle on the `lobby_id` unique index on the table `game_timer`.
pub fn lobby_id(&self) -> GameTimerLobbyIdUnique<'ctx> {
GameTimerLobbyIdUnique {
imp: self.imp.get_unique_constraint::<u32>("lobby_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> GameTimerLobbyIdUnique<'ctx> {
/// Find the subscribed row whose `lobby_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<GameTimer> {
self.imp.find(col_val)
}
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -18,8 +12,6 @@ pub struct GameTimer {
pub scheduled_at: __sdk::ScheduleAt,
}
impl __sdk::InModule for GameTimer {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -20,8 +14,8 @@ impl From<JoinOrCreateLobbyArgs> for super::Reducer {
fn from(args: JoinOrCreateLobbyArgs) -> Self {
Self::JoinOrCreateLobby {
lobby_id: args.lobby_id,
}
}
}
}
}
impl __sdk::InModule for JoinOrCreateLobbyArgs {
@ -40,8 +34,7 @@ pub trait join_or_create_lobby {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_join_or_create_lobby`] callbacks.
fn join_or_create_lobby(&self, lobby_id: u32,
) -> __sdk::Result<()>;
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -49,40 +42,46 @@ pub trait join_or_create_lobby {
///
/// The returned [`JoinOrCreateLobbyCallbackId`] can be passed to [`Self::remove_on_join_or_create_lobby`]
/// to cancel the callback.
fn on_join_or_create_lobby(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> JoinOrCreateLobbyCallbackId;
fn on_join_or_create_lobby(
&self,
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> JoinOrCreateLobbyCallbackId;
/// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`],
/// causing it not to run in the future.
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId);
}
impl join_or_create_lobby for super::RemoteReducers {
fn join_or_create_lobby(&self, lobby_id: u32,
) -> __sdk::Result<()> {
self.imp.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id, })
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> {
self.imp
.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id })
}
fn on_join_or_create_lobby(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> JoinOrCreateLobbyCallbackId {
JoinOrCreateLobbyCallbackId(self.imp.on_reducer(
"join_or_create_lobby",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::JoinOrCreateLobby {
lobby_id,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::JoinOrCreateLobby { lobby_id },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, lobby_id, )
} = ctx
else {
unreachable!()
};
callback(ctx, lobby_id)
}),
))
}
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) {
self.imp.remove_on_reducer("join_or_create_lobby", callback.0)
self.imp
.remove_on_reducer("join_or_create_lobby", callback.0)
}
}
@ -102,7 +101,7 @@ pub trait set_flags_for_join_or_create_lobby {
impl set_flags_for_join_or_create_lobby for super::SetReducerFlags {
fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags) {
self.imp.set_call_reducer_flags("join_or_create_lobby", flags);
self.imp
.set_call_reducer_flags("join_or_create_lobby", flags);
}
}

View file

@ -2,15 +2,10 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::game_state_type::GameState;
use super::lobby_type::Lobby;
use super::player_or_bot_type::PlayerOrBot;
use super::game_state_type::GameState;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `lobby`.
///
@ -51,8 +46,12 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
type Row = Lobby;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = Lobby> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = Lobby> + '_ {
self.imp.iter()
}
type InsertCallbackId = LobbyInsertCallbackId;
@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
let _table = client_cache.get_or_make_table::<Lobby>("lobby");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
}
pub struct LobbyUpdateCallbackId(__sdk::CallbackId);
@ -104,46 +102,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<Lobby>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<Lobby>",
"TableUpdate",
).with_cause(e).into()
__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>,
}
/// 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> 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)
}
}
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)
}
}

View file

@ -2,28 +2,21 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::player_or_bot_type::PlayerOrBot;
use super::game_state_type::GameState;
use super::player_or_bot_type::PlayerOrBot;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct Lobby {
pub id: u32,
pub players: Vec::<PlayerOrBot>,
pub players: Vec<PlayerOrBot>,
pub dealer_idx: u8,
pub current_idx: u8,
pub game_state: GameState,
}
impl __sdk::InModule for Lobby {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,8 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::player_type::Player;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `logged_out_player`.
///
@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for LoggedOutPlayerTableHandle<'ctx> {
type Row = Player;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = Player> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = Player> + '_ {
self.imp.iter()
}
type InsertCallbackId = LoggedOutPlayerInsertCallbackId;
@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for LoggedOutPlayerTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<Player>("logged_out_player");
let _table = client_cache.get_or_make_table::<Player>("logged_out_player");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
}
@ -103,76 +101,75 @@ impl<'ctx> __sdk::TableWithPrimaryKey for LoggedOutPlayerTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<Player>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<Player>",
"TableUpdate",
).with_cause(e).into()
__sdk::InternalError::failed_parse("TableUpdate<Player>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `id` unique index on the table `logged_out_player`,
/// which allows point queries on the field of the same name
/// via the [`LoggedOutPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.logged_out_player().id().find(...)`.
pub struct LoggedOutPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Player, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
/// Access to the `id` unique index on the table `logged_out_player`,
/// which allows point queries on the field of the same name
/// via the [`LoggedOutPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.logged_out_player().id().find(...)`.
pub struct LoggedOutPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Player, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LoggedOutPlayerTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `logged_out_player`.
pub fn id(&self) -> LoggedOutPlayerIdUnique<'ctx> {
LoggedOutPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
impl<'ctx> LoggedOutPlayerTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `logged_out_player`.
pub fn id(&self) -> LoggedOutPlayerIdUnique<'ctx> {
LoggedOutPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> LoggedOutPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<Player> {
self.imp.find(col_val)
}
}
/// Access to the `identity` unique index on the table `logged_out_player`,
/// which allows point queries on the field of the same name
/// via the [`LoggedOutPlayerIdentityUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.logged_out_player().identity().find(...)`.
pub struct LoggedOutPlayerIdentityUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Player, __sdk::Identity>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LoggedOutPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<Player> {
self.imp.find(col_val)
}
}
impl<'ctx> LoggedOutPlayerTableHandle<'ctx> {
/// Get a handle on the `identity` unique index on the table `logged_out_player`.
pub fn identity(&self) -> LoggedOutPlayerIdentityUnique<'ctx> {
LoggedOutPlayerIdentityUnique {
imp: self.imp.get_unique_constraint::<__sdk::Identity>("identity"),
phantom: std::marker::PhantomData,
}
}
}
/// Access to the `identity` unique index on the table `logged_out_player`,
/// which allows point queries on the field of the same name
/// via the [`LoggedOutPlayerIdentityUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.logged_out_player().identity().find(...)`.
pub struct LoggedOutPlayerIdentityUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Player, __sdk::Identity>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LoggedOutPlayerIdentityUnique<'ctx> {
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &__sdk::Identity) -> Option<Player> {
self.imp.find(col_val)
}
impl<'ctx> LoggedOutPlayerTableHandle<'ctx> {
/// Get a handle on the `identity` unique index on the table `logged_out_player`.
pub fn identity(&self) -> LoggedOutPlayerIdentityUnique<'ctx> {
LoggedOutPlayerIdentityUnique {
imp: self
.imp
.get_unique_constraint::<__sdk::Identity>("identity"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> LoggedOutPlayerIdentityUnique<'ctx> {
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &__sdk::Identity) -> Option<Player> {
self.imp.find(col_val)
}
}

View file

@ -1,103 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct LoginOrAddPlayerArgs {}
impl From<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);
}
}

View file

@ -4,80 +4,77 @@
// This was generated using spacetimedb cli version 1.11.3 (commit 02449737ca3b29e7e39679fccbef541a50f32094).
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
pub mod bot_type;
pub mod db_tile_type;
pub mod db_wall_type;
pub mod dragon_type;
pub mod game_state_type;
pub mod game_timer_type;
pub mod lobby_type;
pub mod player_type;
pub mod player_clock_type;
pub mod player_hand_type;
pub mod player_or_bot_type;
pub mod rank_type;
pub mod suit_type;
pub mod tile_type;
pub mod turn_state_type;
pub mod wind_type;
pub mod add_bot_reducer;
pub mod advance_game_reducer;
pub mod bot_table;
pub mod bot_type;
pub mod clear_all_reducer;
pub mod connect_reducer;
pub mod db_tile_type;
pub mod db_wall_type;
pub mod discard_tile_reducer;
pub mod disconnect_reducer;
pub mod join_or_create_lobby_reducer;
pub mod set_ready_reducer;
pub mod bot_table;
pub mod dragon_type;
pub mod game_state_type;
pub mod game_timer_table;
pub mod game_timer_type;
pub mod join_or_create_lobby_reducer;
pub mod lobby_table;
pub mod lobby_type;
pub mod logged_out_player_table;
pub mod player_table;
pub mod player_clock_table;
pub mod player_clock_type;
pub mod player_hand_table;
pub mod player_hand_type;
pub mod player_or_bot_type;
pub mod player_table;
pub mod player_type;
pub mod rank_type;
pub mod set_ready_reducer;
pub mod suit_type;
pub mod tile_table;
pub mod tile_type;
pub mod turn_state_type;
pub mod wall_table;
pub mod wind_type;
pub use bot_type::Bot;
pub use db_tile_type::DbTile;
pub use db_wall_type::DbWall;
pub use dragon_type::Dragon;
pub use game_state_type::GameState;
pub use game_timer_type::GameTimer;
pub use lobby_type::Lobby;
pub use player_type::Player;
pub use player_clock_type::PlayerClock;
pub use player_hand_type::PlayerHand;
pub use player_or_bot_type::PlayerOrBot;
pub use rank_type::Rank;
pub use suit_type::Suit;
pub use tile_type::Tile;
pub use turn_state_type::TurnState;
pub use wind_type::Wind;
pub use bot_table::*;
pub use game_timer_table::*;
pub use lobby_table::*;
pub use logged_out_player_table::*;
pub use player_table::*;
pub use player_clock_table::*;
pub use player_hand_table::*;
pub use tile_table::*;
pub use wall_table::*;
pub use add_bot_reducer::{add_bot, set_flags_for_add_bot, AddBotCallbackId};
pub use advance_game_reducer::{advance_game, set_flags_for_advance_game, AdvanceGameCallbackId};
pub use bot_table::*;
pub use bot_type::Bot;
pub use clear_all_reducer::{clear_all, set_flags_for_clear_all, ClearAllCallbackId};
pub use connect_reducer::{connect, set_flags_for_connect, ConnectCallbackId};
pub use db_tile_type::DbTile;
pub use db_wall_type::DbWall;
pub use discard_tile_reducer::{discard_tile, set_flags_for_discard_tile, DiscardTileCallbackId};
pub use disconnect_reducer::{disconnect, set_flags_for_disconnect, DisconnectCallbackId};
pub use join_or_create_lobby_reducer::{join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId};
pub use set_ready_reducer::{set_ready, set_flags_for_set_ready, SetReadyCallbackId};
pub use dragon_type::Dragon;
pub use game_state_type::GameState;
pub use game_timer_table::*;
pub use game_timer_type::GameTimer;
pub use join_or_create_lobby_reducer::{
join_or_create_lobby, set_flags_for_join_or_create_lobby, JoinOrCreateLobbyCallbackId,
};
pub use lobby_table::*;
pub use lobby_type::Lobby;
pub use logged_out_player_table::*;
pub use player_clock_table::*;
pub use player_clock_type::PlayerClock;
pub use player_hand_table::*;
pub use player_hand_type::PlayerHand;
pub use player_or_bot_type::PlayerOrBot;
pub use player_table::*;
pub use player_type::Player;
pub use rank_type::Rank;
pub use set_ready_reducer::{set_flags_for_set_ready, set_ready, SetReadyCallbackId};
pub use suit_type::Suit;
pub use tile_table::*;
pub use tile_type::Tile;
pub use turn_state_type::TurnState;
pub use wall_table::*;
pub use wind_type::Wind;
#[derive(Clone, PartialEq, Debug)]
@ -87,27 +84,16 @@ pub use set_ready_reducer::{set_ready, set_flags_for_set_ready, SetReadyCallback
/// to indicate which reducer caused the event.
pub enum Reducer {
AddBot {
lobby_id: u32,
} ,
AdvanceGame {
game_timer: GameTimer,
} ,
ClearAll ,
Connect ,
DiscardTile {
tile_id: u32,
} ,
Disconnect ,
JoinOrCreateLobby {
lobby_id: u32,
} ,
SetReady {
ready: bool,
} ,
AddBot { lobby_id: u32 },
AdvanceGame { game_timer: GameTimer },
ClearAll,
Connect,
DiscardTile { tile_id: u32 },
Disconnect,
JoinOrCreateLobby { lobby_id: u32 },
SetReady { ready: bool },
}
impl __sdk::InModule for Reducer {
type Module = RemoteModule;
}
@ -115,7 +101,7 @@ impl __sdk::InModule for Reducer {
impl __sdk::Reducer for Reducer {
fn reducer_name(&self) -> &'static str {
match self {
Reducer::AddBot { .. } => "add_bot",
Reducer::AddBot { .. } => "add_bot",
Reducer::AdvanceGame { .. } => "advance_game",
Reducer::ClearAll => "clear_all",
Reducer::Connect => "connect",
@ -124,31 +110,77 @@ impl __sdk::Reducer for Reducer {
Reducer::JoinOrCreateLobby { .. } => "join_or_create_lobby",
Reducer::SetReady { .. } => "set_ready",
_ => unreachable!(),
}
}
}
}
}
impl TryFrom<__ws::ReducerCallInfo<__ws::BsatnFormat>> for Reducer {
type Error = __sdk::Error;
fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result<Self> {
type Error = __sdk::Error;
fn try_from(value: __ws::ReducerCallInfo<__ws::BsatnFormat>) -> __sdk::Result<Self> {
match &value.reducer_name[..] {
"add_bot" => Ok(__sdk::parse_reducer_args::<add_bot_reducer::AddBotArgs>("add_bot", &value.args)?.into()),
"advance_game" => Ok(__sdk::parse_reducer_args::<advance_game_reducer::AdvanceGameArgs>("advance_game", &value.args)?.into()),
"clear_all" => Ok(__sdk::parse_reducer_args::<clear_all_reducer::ClearAllArgs>("clear_all", &value.args)?.into()),
"connect" => Ok(__sdk::parse_reducer_args::<connect_reducer::ConnectArgs>("connect", &value.args)?.into()),
"discard_tile" => Ok(__sdk::parse_reducer_args::<discard_tile_reducer::DiscardTileArgs>("discard_tile", &value.args)?.into()),
"disconnect" => Ok(__sdk::parse_reducer_args::<disconnect_reducer::DisconnectArgs>("disconnect", &value.args)?.into()),
"join_or_create_lobby" => Ok(__sdk::parse_reducer_args::<join_or_create_lobby_reducer::JoinOrCreateLobbyArgs>("join_or_create_lobby", &value.args)?.into()),
"set_ready" => Ok(__sdk::parse_reducer_args::<set_ready_reducer::SetReadyArgs>("set_ready", &value.args)?.into()),
unknown => Err(__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo").into()),
}
}
"add_bot" => Ok(__sdk::parse_reducer_args::<add_bot_reducer::AddBotArgs>(
"add_bot",
&value.args,
)?
.into()),
"advance_game" => Ok(
__sdk::parse_reducer_args::<advance_game_reducer::AdvanceGameArgs>(
"advance_game",
&value.args,
)?
.into(),
),
"clear_all" => Ok(
__sdk::parse_reducer_args::<clear_all_reducer::ClearAllArgs>(
"clear_all",
&value.args,
)?
.into(),
),
"connect" => Ok(__sdk::parse_reducer_args::<connect_reducer::ConnectArgs>(
"connect",
&value.args,
)?
.into()),
"discard_tile" => Ok(
__sdk::parse_reducer_args::<discard_tile_reducer::DiscardTileArgs>(
"discard_tile",
&value.args,
)?
.into(),
),
"disconnect" => Ok(
__sdk::parse_reducer_args::<disconnect_reducer::DisconnectArgs>(
"disconnect",
&value.args,
)?
.into(),
),
"join_or_create_lobby" => Ok(__sdk::parse_reducer_args::<
join_or_create_lobby_reducer::JoinOrCreateLobbyArgs,
>("join_or_create_lobby", &value.args)?
.into()),
"set_ready" => Ok(
__sdk::parse_reducer_args::<set_ready_reducer::SetReadyArgs>(
"set_ready",
&value.args,
)?
.into(),
),
unknown => {
Err(
__sdk::InternalError::unknown_name("reducer", unknown, "ReducerCallInfo")
.into(),
)
}
}
}
}
#[derive(Default)]
#[allow(non_snake_case)]
#[doc(hidden)]
pub struct DbUpdate {
bot: __sdk::TableUpdate<Bot>,
bot: __sdk::TableUpdate<Bot>,
game_timer: __sdk::TableUpdate<GameTimer>,
lobby: __sdk::TableUpdate<Lobby>,
logged_out_player: __sdk::TableUpdate<Player>,
@ -159,30 +191,47 @@ pub struct DbUpdate {
wall: __sdk::TableUpdate<DbWall>,
}
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[..] {
"bot" => db_update.bot.append(bot_table::parse_table_update(table_update)?),
"game_timer" => db_update.game_timer.append(game_timer_table::parse_table_update(table_update)?),
"lobby" => db_update.lobby.append(lobby_table::parse_table_update(table_update)?),
"logged_out_player" => db_update.logged_out_player.append(logged_out_player_table::parse_table_update(table_update)?),
"player" => db_update.player.append(player_table::parse_table_update(table_update)?),
"player_clock" => db_update.player_clock.append(player_clock_table::parse_table_update(table_update)?),
"player_hand" => db_update.player_hand.append(player_hand_table::parse_table_update(table_update)?),
"tile" => db_update.tile.append(tile_table::parse_table_update(table_update)?),
"wall" => db_update.wall.append(wall_table::parse_table_update(table_update)?),
"bot" => db_update
.bot
.append(bot_table::parse_table_update(table_update)?),
"game_timer" => db_update
.game_timer
.append(game_timer_table::parse_table_update(table_update)?),
"lobby" => db_update
.lobby
.append(lobby_table::parse_table_update(table_update)?),
"logged_out_player" => db_update
.logged_out_player
.append(logged_out_player_table::parse_table_update(table_update)?),
"player" => db_update
.player
.append(player_table::parse_table_update(table_update)?),
"player_clock" => db_update
.player_clock
.append(player_clock_table::parse_table_update(table_update)?),
"player_hand" => db_update
.player_hand
.append(player_hand_table::parse_table_update(table_update)?),
"tile" => db_update
.tile
.append(tile_table::parse_table_update(table_update)?),
"wall" => db_update
.wall
.append(wall_table::parse_table_update(table_update)?),
unknown => {
return Err(__sdk::InternalError::unknown_name(
"table",
unknown,
"DatabaseUpdate",
).into());
)
.into());
}
}
}
@ -195,28 +244,49 @@ impl __sdk::InModule for DbUpdate {
}
impl __sdk::DbUpdate for DbUpdate {
fn apply_to_client_cache(&self, cache: &mut __sdk::ClientCache<RemoteModule>) -> AppliedDiff<'_> {
let mut diff = AppliedDiff::default();
diff.bot = cache.apply_diff_to_table::<Bot>("bot", &self.bot).with_updates_by_pk(|row| &row.id);
diff.game_timer = cache.apply_diff_to_table::<GameTimer>("game_timer", &self.game_timer).with_updates_by_pk(|row| &row.id);
diff.lobby = cache.apply_diff_to_table::<Lobby>("lobby", &self.lobby).with_updates_by_pk(|row| &row.id);
diff.logged_out_player = cache.apply_diff_to_table::<Player>("logged_out_player", &self.logged_out_player).with_updates_by_pk(|row| &row.identity);
diff.player = cache.apply_diff_to_table::<Player>("player", &self.player).with_updates_by_pk(|row| &row.identity);
diff.player_clock = cache.apply_diff_to_table::<PlayerClock>("player_clock", &self.player_clock).with_updates_by_pk(|row| &row.id);
diff.player_hand = cache.apply_diff_to_table::<PlayerHand>("player_hand", &self.player_hand).with_updates_by_pk(|row| &row.id);
diff.tile = cache.apply_diff_to_table::<DbTile>("tile", &self.tile).with_updates_by_pk(|row| &row.id);
diff.wall = cache.apply_diff_to_table::<DbWall>("wall", &self.wall).with_updates_by_pk(|row| &row.lobby_id);
fn apply_to_client_cache(
&self,
cache: &mut __sdk::ClientCache<RemoteModule>,
) -> AppliedDiff<'_> {
let mut diff = AppliedDiff::default();
diff
}
diff.bot = cache
.apply_diff_to_table::<Bot>("bot", &self.bot)
.with_updates_by_pk(|row| &row.id);
diff.game_timer = cache
.apply_diff_to_table::<GameTimer>("game_timer", &self.game_timer)
.with_updates_by_pk(|row| &row.id);
diff.lobby = cache
.apply_diff_to_table::<Lobby>("lobby", &self.lobby)
.with_updates_by_pk(|row| &row.id);
diff.logged_out_player = cache
.apply_diff_to_table::<Player>("logged_out_player", &self.logged_out_player)
.with_updates_by_pk(|row| &row.identity);
diff.player = cache
.apply_diff_to_table::<Player>("player", &self.player)
.with_updates_by_pk(|row| &row.identity);
diff.player_clock = cache
.apply_diff_to_table::<PlayerClock>("player_clock", &self.player_clock)
.with_updates_by_pk(|row| &row.id);
diff.player_hand = cache
.apply_diff_to_table::<PlayerHand>("player_hand", &self.player_hand)
.with_updates_by_pk(|row| &row.id);
diff.tile = cache
.apply_diff_to_table::<DbTile>("tile", &self.tile)
.with_updates_by_pk(|row| &row.id);
diff.wall = cache
.apply_diff_to_table::<DbWall>("wall", &self.wall)
.with_updates_by_pk(|row| &row.lobby_id);
diff
}
}
#[derive(Default)]
#[allow(non_snake_case)]
#[doc(hidden)]
pub struct AppliedDiff<'r> {
bot: __sdk::TableAppliedDiff<'r, Bot>,
bot: __sdk::TableAppliedDiff<'r, Bot>,
game_timer: __sdk::TableAppliedDiff<'r, GameTimer>,
lobby: __sdk::TableAppliedDiff<'r, Lobby>,
logged_out_player: __sdk::TableAppliedDiff<'r, Player>,
@ -228,25 +298,35 @@ pub struct AppliedDiff<'r> {
__unused: std::marker::PhantomData<&'r ()>,
}
impl __sdk::InModule for AppliedDiff<'_> {
type Module = RemoteModule;
}
impl<'r> __sdk::AppliedDiff<'r> for AppliedDiff<'r> {
fn invoke_row_callbacks(&self, event: &EventContext, callbacks: &mut __sdk::DbCallbacks<RemoteModule>) {
callbacks.invoke_table_row_callbacks::<Bot>("bot", &self.bot, event);
fn invoke_row_callbacks(
&self,
event: &EventContext,
callbacks: &mut __sdk::DbCallbacks<RemoteModule>,
) {
callbacks.invoke_table_row_callbacks::<Bot>("bot", &self.bot, event);
callbacks.invoke_table_row_callbacks::<GameTimer>("game_timer", &self.game_timer, event);
callbacks.invoke_table_row_callbacks::<Lobby>("lobby", &self.lobby, event);
callbacks.invoke_table_row_callbacks::<Player>("logged_out_player", &self.logged_out_player, event);
callbacks.invoke_table_row_callbacks::<Player>(
"logged_out_player",
&self.logged_out_player,
event,
);
callbacks.invoke_table_row_callbacks::<Player>("player", &self.player, event);
callbacks.invoke_table_row_callbacks::<PlayerClock>("player_clock", &self.player_clock, event);
callbacks.invoke_table_row_callbacks::<PlayerClock>(
"player_clock",
&self.player_clock,
event,
);
callbacks.invoke_table_row_callbacks::<PlayerHand>("player_hand", &self.player_hand, event);
callbacks.invoke_table_row_callbacks::<DbTile>("tile", &self.tile, event);
callbacks.invoke_table_row_callbacks::<DbWall>("wall", &self.wall, event);
}
}
}
#[doc(hidden)]
pub struct RemoteModule;
@ -499,7 +579,6 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle {
fn unsubscribe(self) -> __sdk::Result<()> {
self.imp.unsubscribe_then(None)
}
}
/// Alias trait for a [`__sdk::DbContext`] connected to this module,
@ -507,19 +586,25 @@ impl __sdk::SubscriptionHandle for SubscriptionHandle {
///
/// Users can use this trait as a boundary on definitions which should accept
/// either a [`DbConnection`] or an [`EventContext`] and operate on either.
pub trait RemoteDbContext: __sdk::DbContext<
pub trait RemoteDbContext:
__sdk::DbContext<
DbView = RemoteTables,
Reducers = RemoteReducers,
SetReducerFlags = SetReducerFlags,
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
> {}
impl<Ctx: __sdk::DbContext<
DbView = RemoteTables,
Reducers = RemoteReducers,
SetReducerFlags = SetReducerFlags,
SubscriptionBuilder = __sdk::SubscriptionBuilder<RemoteModule>,
>> RemoteDbContext for Ctx {}
>
{
}
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.
@ -944,7 +1029,6 @@ impl __sdk::DbContext for ErrorContext {
impl __sdk::ErrorContext for ErrorContext {}
impl __sdk::SpacetimeModule for RemoteModule {
type DbConnection = DbConnection;
type EventContext = EventContext;
type ReducerEventContext = ReducerEventContext;
@ -959,8 +1043,8 @@ impl __sdk::SpacetimeModule for RemoteModule {
type AppliedDiff<'r> = AppliedDiff<'r>;
type SubscriptionHandle = SubscriptionHandle;
fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
bot_table::register_table(client_cache);
fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
bot_table::register_table(client_cache);
game_timer_table::register_table(client_cache);
lobby_table::register_table(client_cache);
logged_out_player_table::register_table(client_cache);
@ -969,5 +1053,5 @@ fn register_tables(client_cache: &mut __sdk::ClientCache<Self>) {
player_hand_table::register_table(client_cache);
tile_table::register_table(client_cache);
wall_table::register_table(client_cache);
}
}
}

View file

@ -2,13 +2,8 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::player_clock_type::PlayerClock;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `player_clock`.
///
@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> {
type Row = PlayerClock;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = PlayerClock> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = PlayerClock> + '_ {
self.imp.iter()
}
type InsertCallbackId = PlayerClockInsertCallbackId;
@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for PlayerClockTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<PlayerClock>("player_clock");
let _table = client_cache.get_or_make_table::<PlayerClock>("player_clock");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
_table.add_unique_constraint::<u32>("player_id", |row| &row.player_id);
}
@ -103,76 +101,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerClockTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<PlayerClock>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<PlayerClock>",
"TableUpdate",
).with_cause(e).into()
__sdk::InternalError::failed_parse("TableUpdate<PlayerClock>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `id` unique index on the table `player_clock`,
/// which allows point queries on the field of the same name
/// via the [`PlayerClockIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_clock().id().find(...)`.
pub struct PlayerClockIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerClock, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
/// Access to the `id` unique index on the table `player_clock`,
/// which allows point queries on the field of the same name
/// via the [`PlayerClockIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_clock().id().find(...)`.
pub struct PlayerClockIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerClock, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerClockTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `player_clock`.
pub fn id(&self) -> PlayerClockIdUnique<'ctx> {
PlayerClockIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
impl<'ctx> PlayerClockTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `player_clock`.
pub fn id(&self) -> PlayerClockIdUnique<'ctx> {
PlayerClockIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> PlayerClockIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerClock> {
self.imp.find(col_val)
}
}
/// Access to the `player_id` unique index on the table `player_clock`,
/// which allows point queries on the field of the same name
/// via the [`PlayerClockPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_clock().player_id().find(...)`.
pub struct PlayerClockPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerClock, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerClockIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerClock> {
self.imp.find(col_val)
}
}
impl<'ctx> PlayerClockTableHandle<'ctx> {
/// Get a handle on the `player_id` unique index on the table `player_clock`.
pub fn player_id(&self) -> PlayerClockPlayerIdUnique<'ctx> {
PlayerClockPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("player_id"),
phantom: std::marker::PhantomData,
}
}
}
/// Access to the `player_id` unique index on the table `player_clock`,
/// which allows point queries on the field of the same name
/// via the [`PlayerClockPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_clock().player_id().find(...)`.
pub struct PlayerClockPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerClock, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerClockPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `player_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerClock> {
self.imp.find(col_val)
}
impl<'ctx> PlayerClockTableHandle<'ctx> {
/// Get a handle on the `player_id` unique index on the table `player_clock`.
pub fn player_id(&self) -> PlayerClockPlayerIdUnique<'ctx> {
PlayerClockPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("player_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> PlayerClockPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `player_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerClock> {
self.imp.find(col_val)
}
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -19,8 +13,6 @@ pub struct PlayerClock {
pub total: u16,
}
impl __sdk::InModule for PlayerClock {
type Module = super::RemoteModule;
}

View file

@ -2,15 +2,10 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::db_tile_type::DbTile;
use super::player_hand_type::PlayerHand;
use super::turn_state_type::TurnState;
use super::db_tile_type::DbTile;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `player_hand`.
///
@ -51,8 +46,12 @@ impl<'ctx> __sdk::Table for PlayerHandTableHandle<'ctx> {
type Row = PlayerHand;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = PlayerHand> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = PlayerHand> + '_ {
self.imp.iter()
}
type InsertCallbackId = PlayerHandInsertCallbackId;
@ -83,8 +82,7 @@ impl<'ctx> __sdk::Table for PlayerHandTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<PlayerHand>("player_hand");
let _table = client_cache.get_or_make_table::<PlayerHand>("player_hand");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
_table.add_unique_constraint::<u32>("player_id", |row| &row.player_id);
}
@ -105,76 +103,73 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerHandTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<PlayerHand>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<PlayerHand>",
"TableUpdate",
).with_cause(e).into()
__sdk::InternalError::failed_parse("TableUpdate<PlayerHand>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `id` unique index on the table `player_hand`,
/// which allows point queries on the field of the same name
/// via the [`PlayerHandIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_hand().id().find(...)`.
pub struct PlayerHandIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerHand, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
/// Access to the `id` unique index on the table `player_hand`,
/// which allows point queries on the field of the same name
/// via the [`PlayerHandIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_hand().id().find(...)`.
pub struct PlayerHandIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerHand, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerHandTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `player_hand`.
pub fn id(&self) -> PlayerHandIdUnique<'ctx> {
PlayerHandIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
impl<'ctx> PlayerHandTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `player_hand`.
pub fn id(&self) -> PlayerHandIdUnique<'ctx> {
PlayerHandIdUnique {
imp: self.imp.get_unique_constraint::<u32>("id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> PlayerHandIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerHand> {
self.imp.find(col_val)
}
}
/// Access to the `player_id` unique index on the table `player_hand`,
/// which allows point queries on the field of the same name
/// via the [`PlayerHandPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_hand().player_id().find(...)`.
pub struct PlayerHandPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerHand, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerHandIdUnique<'ctx> {
/// Find the subscribed row whose `id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerHand> {
self.imp.find(col_val)
}
}
impl<'ctx> PlayerHandTableHandle<'ctx> {
/// Get a handle on the `player_id` unique index on the table `player_hand`.
pub fn player_id(&self) -> PlayerHandPlayerIdUnique<'ctx> {
PlayerHandPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("player_id"),
phantom: std::marker::PhantomData,
}
}
}
/// Access to the `player_id` unique index on the table `player_hand`,
/// which allows point queries on the field of the same name
/// via the [`PlayerHandPlayerIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player_hand().player_id().find(...)`.
pub struct PlayerHandPlayerIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<PlayerHand, u32>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerHandPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `player_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerHand> {
self.imp.find(col_val)
}
impl<'ctx> PlayerHandTableHandle<'ctx> {
/// Get a handle on the `player_id` unique index on the table `player_hand`.
pub fn player_id(&self) -> PlayerHandPlayerIdUnique<'ctx> {
PlayerHandPlayerIdUnique {
imp: self.imp.get_unique_constraint::<u32>("player_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> PlayerHandPlayerIdUnique<'ctx> {
/// Find the subscribed row whose `player_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &u32) -> Option<PlayerHand> {
self.imp.find(col_val)
}
}

View file

@ -2,15 +2,10 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::turn_state_type::TurnState;
use super::db_tile_type::DbTile;
use super::turn_state_type::TurnState;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -18,13 +13,11 @@ pub struct PlayerHand {
pub id: u32,
pub player_id: u32,
pub turn_state: TurnState,
pub pond: Vec::<DbTile>,
pub hand: Vec::<DbTile>,
pub working_tile: Option::<DbTile>,
pub pond: Vec<DbTile>,
pub hand: Vec<DbTile>,
pub working_tile: Option<DbTile>,
}
impl __sdk::InModule for PlayerHand {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -16,12 +10,8 @@ pub enum PlayerOrBot {
Player(u32),
Bot(u32),
}
impl __sdk::InModule for PlayerOrBot {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,8 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::player_type::Player;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `player`.
///
@ -49,8 +44,12 @@ impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> {
type Row = Player;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = Player> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = Player> + '_ {
self.imp.iter()
}
type InsertCallbackId = PlayerInsertCallbackId;
@ -81,8 +80,7 @@ impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<Player>("player");
let _table = client_cache.get_or_make_table::<Player>("player");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
}
@ -103,76 +101,75 @@ impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<Player>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<Player>",
"TableUpdate",
).with_cause(e).into()
__sdk::InternalError::failed_parse("TableUpdate<Player>", "TableUpdate")
.with_cause(e)
.into()
})
}
/// Access to the `id` unique index on the table `player`,
/// which allows point queries on the field of the same name
/// via the [`PlayerIdUnique::find`] method.
///
/// 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>,
}
/// 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> 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)
}
}
/// 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> 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)
}
}
impl<'ctx> PlayerTableHandle<'ctx> {
/// Get a handle on the `identity` unique index on the table `player`.
pub fn identity(&self) -> PlayerIdentityUnique<'ctx> {
PlayerIdentityUnique {
imp: self.imp.get_unique_constraint::<__sdk::Identity>("identity"),
phantom: std::marker::PhantomData,
}
}
}
/// Access to the `identity` unique index on the table `player`,
/// which allows point queries on the field of the same name
/// via the [`PlayerIdentityUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.player().identity().find(...)`.
pub struct PlayerIdentityUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<Player, __sdk::Identity>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> PlayerIdentityUnique<'ctx> {
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &__sdk::Identity) -> Option<Player> {
self.imp.find(col_val)
}
impl<'ctx> PlayerTableHandle<'ctx> {
/// Get a handle on the `identity` unique index on the table `player`.
pub fn identity(&self) -> PlayerIdentityUnique<'ctx> {
PlayerIdentityUnique {
imp: self
.imp
.get_unique_constraint::<__sdk::Identity>("identity"),
phantom: std::marker::PhantomData,
}
}
}
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)
}
}

View file

@ -2,27 +2,19 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct Player {
pub id: u32,
pub identity: __sdk::Identity,
pub name: Option::<String>,
pub name: Option<String>,
pub lobby_id: u32,
pub ready: bool,
pub sort: bool,
}
impl __sdk::InModule for Player {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -16,8 +10,6 @@ pub struct Rank {
pub number: u8,
}
impl __sdk::InModule for Rank {
type Module = super::RemoteModule;
}

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -18,10 +12,8 @@ pub(super) struct SetReadyArgs {
impl From<SetReadyArgs> for super::Reducer {
fn from(args: SetReadyArgs) -> Self {
Self::SetReady {
ready: args.ready,
}
}
Self::SetReady { ready: args.ready }
}
}
impl __sdk::InModule for SetReadyArgs {
@ -40,8 +32,7 @@ pub trait set_ready {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_set_ready`] callbacks.
fn set_ready(&self, ready: bool,
) -> __sdk::Result<()>;
fn set_ready(&self, ready: bool) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -49,35 +40,39 @@ pub trait set_ready {
///
/// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`]
/// to cancel the callback.
fn on_set_ready(&self, callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static) -> SetReadyCallbackId;
fn on_set_ready(
&self,
callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static,
) -> SetReadyCallbackId;
/// Cancel a callback previously registered by [`Self::on_set_ready`],
/// causing it not to run in the future.
fn remove_on_set_ready(&self, callback: SetReadyCallbackId);
}
impl set_ready for super::RemoteReducers {
fn set_ready(&self, ready: bool,
) -> __sdk::Result<()> {
self.imp.call_reducer("set_ready", SetReadyArgs { ready, })
fn set_ready(&self, ready: bool) -> __sdk::Result<()> {
self.imp.call_reducer("set_ready", SetReadyArgs { ready })
}
fn on_set_ready(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &bool) + Send + 'static,
) -> SetReadyCallbackId {
SetReadyCallbackId(self.imp.on_reducer(
"set_ready",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::SetReady {
ready,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::SetReady { ready },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, ready, )
} = ctx
else {
unreachable!()
};
callback(ctx, ready)
}),
))
}
@ -105,4 +100,3 @@ impl set_flags_for_set_ready for super::SetReducerFlags {
self.imp.set_call_reducer_flags("set_ready", flags);
}
}

View file

@ -1,105 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct ShuffleDealArgs {
pub lobby_id: u32,
}
impl From<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);
}
}

View file

@ -1,100 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct SkipCallArgs {}
impl From<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);
}
}

View file

@ -1,100 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct StartGameArgs {}
impl From<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);
}
}

View file

@ -2,16 +2,11 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::dragon_type::Dragon;
use super::rank_type::Rank;
use super::wind_type::Wind;
use super::dragon_type::Dragon;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -25,12 +20,8 @@ pub enum Suit {
Wind(Wind),
Dragon(Dragon),
}
impl __sdk::InModule for Suit {
type Module = super::RemoteModule;
}

View file

@ -2,14 +2,9 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::db_tile_type::DbTile;
use super::tile_type::Tile;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `tile`.
///
@ -50,8 +45,12 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> {
type Row = DbTile;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = DbTile> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = DbTile> + '_ {
self.imp.iter()
}
type InsertCallbackId = TileInsertCallbackId;
@ -82,8 +81,7 @@ impl<'ctx> __sdk::Table for TileTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<DbTile>("tile");
let _table = client_cache.get_or_make_table::<DbTile>("tile");
_table.add_unique_constraint::<u32>("id", |row| &row.id);
}
pub struct TileUpdateCallbackId(__sdk::CallbackId);
@ -103,46 +101,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for TileTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<DbTile>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<DbTile>",
"TableUpdate",
).with_cause(e).into()
__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>,
}
/// 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> 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)
}
}
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)
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::suit_type::Suit;
@ -17,8 +12,6 @@ pub struct Tile {
pub suit: Suit,
}
impl __sdk::InModule for Tile {
type Module = super::RemoteModule;
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -24,12 +19,8 @@ pub enum TurnState {
RonChiiPonKan,
End,
}
impl __sdk::InModule for TurnState {
type Module = super::RemoteModule;
}

View file

@ -2,14 +2,9 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::db_wall_type::DbWall;
use super::db_tile_type::DbTile;
use super::db_wall_type::DbWall;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `wall`.
///
@ -50,8 +45,12 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> {
type Row = DbWall;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = DbWall> + '_ { self.imp.iter() }
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = DbWall> + '_ {
self.imp.iter()
}
type InsertCallbackId = WallInsertCallbackId;
@ -82,8 +81,7 @@ impl<'ctx> __sdk::Table for WallTableHandle<'ctx> {
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<DbWall>("wall");
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);
@ -103,46 +101,43 @@ impl<'ctx> __sdk::TableWithPrimaryKey for WallTableHandle<'ctx> {
}
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::TableUpdate<__ws::BsatnFormat>,
) -> __sdk::Result<__sdk::TableUpdate<DbWall>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<DbWall>",
"TableUpdate",
).with_cause(e).into()
__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>,
}
/// 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> 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)
}
}
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)
}
}

View file

@ -2,12 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -20,12 +15,8 @@ pub enum Wind {
Shaa,
Pei,
}
impl __sdk::InModule for Wind {
type Module = super::RemoteModule;
}