state advancer reducer

This commit is contained in:
Tao Tien 2026-02-20 15:36:04 -08:00
parent c12667938e
commit e2c9c815ec
44 changed files with 2063 additions and 773 deletions

View file

@ -2,9 +2,14 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use super::db_tile_type::DbTile;
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use super::db_wall_type::DbWall;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::db_tile_type::DbTile;
/// Table handle for the table `wall`.
///
@ -45,12 +50,8 @@ 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;
@ -81,7 +82,8 @@ 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);
@ -101,43 +103,46 @@ 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>,
}
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,
/// 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> 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> 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)
}
}