2026-02-07 17:46:03 -08:00
|
|
|
// 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)]
|
2026-02-20 15:36:04 -08:00
|
|
|
use spacetimedb_sdk::__codegen::{
|
|
|
|
|
self as __sdk,
|
|
|
|
|
__lib,
|
|
|
|
|
__sats,
|
|
|
|
|
__ws,
|
|
|
|
|
};
|
2026-02-07 17:46:03 -08:00
|
|
|
use super::player_type::Player;
|
|
|
|
|
|
|
|
|
|
/// Table handle for the table `player`.
|
|
|
|
|
///
|
|
|
|
|
/// Obtain a handle from the [`PlayerTableAccess::player`] method on [`super::RemoteTables`],
|
|
|
|
|
/// like `ctx.db.player()`.
|
|
|
|
|
///
|
|
|
|
|
/// Users are encouraged not to explicitly reference this type,
|
|
|
|
|
/// but to directly chain method calls,
|
|
|
|
|
/// like `ctx.db.player().on_insert(...)`.
|
|
|
|
|
pub struct PlayerTableHandle<'ctx> {
|
|
|
|
|
imp: __sdk::TableHandle<Player>,
|
|
|
|
|
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
|
/// Extension trait for access to the table `player`.
|
|
|
|
|
///
|
|
|
|
|
/// Implemented for [`super::RemoteTables`].
|
|
|
|
|
pub trait PlayerTableAccess {
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
|
/// Obtain a [`PlayerTableHandle`], which mediates access to the table `player`.
|
|
|
|
|
fn player(&self) -> PlayerTableHandle<'_>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PlayerTableAccess for super::RemoteTables {
|
|
|
|
|
fn player(&self) -> PlayerTableHandle<'_> {
|
|
|
|
|
PlayerTableHandle {
|
|
|
|
|
imp: self.imp.get_table::<Player>("player"),
|
|
|
|
|
ctx: std::marker::PhantomData,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct PlayerInsertCallbackId(__sdk::CallbackId);
|
|
|
|
|
pub struct PlayerDeleteCallbackId(__sdk::CallbackId);
|
|
|
|
|
|
|
|
|
|
impl<'ctx> __sdk::Table for PlayerTableHandle<'ctx> {
|
|
|
|
|
type Row = Player;
|
|
|
|
|
type EventContext = super::EventContext;
|
|
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
fn count(&self) -> u64 { self.imp.count() }
|
|
|
|
|
fn iter(&self) -> impl Iterator<Item = Player> + '_ { self.imp.iter() }
|
2026-02-07 17:46:03 -08:00
|
|
|
|
|
|
|
|
type InsertCallbackId = PlayerInsertCallbackId;
|
|
|
|
|
|
|
|
|
|
fn on_insert(
|
|
|
|
|
&self,
|
|
|
|
|
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
|
|
|
|
) -> PlayerInsertCallbackId {
|
|
|
|
|
PlayerInsertCallbackId(self.imp.on_insert(Box::new(callback)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn remove_on_insert(&self, callback: PlayerInsertCallbackId) {
|
|
|
|
|
self.imp.remove_on_insert(callback.0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DeleteCallbackId = PlayerDeleteCallbackId;
|
|
|
|
|
|
|
|
|
|
fn on_delete(
|
|
|
|
|
&self,
|
|
|
|
|
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
|
|
|
|
|
) -> PlayerDeleteCallbackId {
|
|
|
|
|
PlayerDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn remove_on_delete(&self, callback: PlayerDeleteCallbackId) {
|
|
|
|
|
self.imp.remove_on_delete(callback.0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
|
2026-02-20 15:36:04 -08:00
|
|
|
|
|
|
|
|
let _table = client_cache.get_or_make_table::<Player>("player");
|
2026-02-08 00:10:10 -08:00
|
|
|
_table.add_unique_constraint::<u32>("id", |row| &row.id);
|
2026-02-20 15:36:04 -08:00
|
|
|
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
|
2026-02-07 17:46:03 -08:00
|
|
|
}
|
|
|
|
|
pub struct PlayerUpdateCallbackId(__sdk::CallbackId);
|
|
|
|
|
|
|
|
|
|
impl<'ctx> __sdk::TableWithPrimaryKey for PlayerTableHandle<'ctx> {
|
|
|
|
|
type UpdateCallbackId = PlayerUpdateCallbackId;
|
|
|
|
|
|
|
|
|
|
fn on_update(
|
|
|
|
|
&self,
|
|
|
|
|
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
|
|
|
|
|
) -> PlayerUpdateCallbackId {
|
|
|
|
|
PlayerUpdateCallbackId(self.imp.on_update(Box::new(callback)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn remove_on_update(&self, callback: PlayerUpdateCallbackId) {
|
|
|
|
|
self.imp.remove_on_update(callback.0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
|
2026-02-07 17:46:03 -08:00
|
|
|
#[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| {
|
2026-02-20 15:36:04 -08:00
|
|
|
__sdk::InternalError::failed_parse(
|
|
|
|
|
"TableUpdate<Player>",
|
|
|
|
|
"TableUpdate",
|
|
|
|
|
).with_cause(e).into()
|
2026-02-07 17:46:03 -08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
/// 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>,
|
2026-02-07 17:46:03 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-08 00:10:10 -08:00
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
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>,
|
|
|
|
|
}
|
2026-02-08 00:10:10 -08:00
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-08 00:10:10 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-20 15:36:04 -08:00
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|