state advancer reducer
This commit is contained in:
parent
c12667938e
commit
e2c9c815ec
44 changed files with 2063 additions and 773 deletions
|
|
@ -2,9 +2,15 @@
|
|||
// 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 spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
|
||||
|
||||
/// Table handle for the table `bot`.
|
||||
///
|
||||
|
|
@ -45,12 +51,8 @@ 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;
|
||||
|
||||
|
|
@ -81,7 +83,8 @@ 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);
|
||||
|
|
@ -101,43 +104,46 @@ 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>,
|
||||
}
|
||||
|
||||
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,
|
||||
/// 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> 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> 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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue