jong/jong-db/src/db/game_timer_table.rs

190 lines
6.5 KiB
Rust
Raw Normal View History

2026-02-20 15:36:04 -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)]
use super::game_timer_type::GameTimer;
2026-02-22 00:08:02 -08:00
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
2026-02-20 15:36:04 -08:00
/// Table handle for the table `game_timer`.
///
/// Obtain a handle from the [`GameTimerTableAccess::game_timer`] method on [`super::RemoteTables`],
/// like `ctx.db.game_timer()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.game_timer().on_insert(...)`.
pub struct GameTimerTableHandle<'ctx> {
imp: __sdk::TableHandle<GameTimer>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `game_timer`.
///
/// Implemented for [`super::RemoteTables`].
pub trait GameTimerTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`GameTimerTableHandle`], which mediates access to the table `game_timer`.
fn game_timer(&self) -> GameTimerTableHandle<'_>;
}
impl GameTimerTableAccess for super::RemoteTables {
fn game_timer(&self) -> GameTimerTableHandle<'_> {
GameTimerTableHandle {
imp: self.imp.get_table::<GameTimer>("game_timer"),
ctx: std::marker::PhantomData,
}
}
}
pub struct GameTimerInsertCallbackId(__sdk::CallbackId);
pub struct GameTimerDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for GameTimerTableHandle<'ctx> {
type Row = GameTimer;
type EventContext = super::EventContext;
2026-02-22 00:08:02 -08:00
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = GameTimer> + '_ {
self.imp.iter()
}
2026-02-20 15:36:04 -08:00
type InsertCallbackId = GameTimerInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> GameTimerInsertCallbackId {
GameTimerInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: GameTimerInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = GameTimerDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> GameTimerDeleteCallbackId {
GameTimerDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: GameTimerDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
2026-02-22 00:08:02 -08:00
let _table = client_cache.get_or_make_table::<GameTimer>("game_timer");
2026-02-20 15:36:04 -08:00
_table.add_unique_constraint::<u64>("id", |row| &row.id);
_table.add_unique_constraint::<u32>("lobby_id", |row| &row.lobby_id);
}
pub struct GameTimerUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for GameTimerTableHandle<'ctx> {
type UpdateCallbackId = GameTimerUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> GameTimerUpdateCallbackId {
GameTimerUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: GameTimerUpdateCallbackId) {
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<GameTimer>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
2026-02-22 00:08:02 -08:00
__sdk::InternalError::failed_parse("TableUpdate<GameTimer>", "TableUpdate")
.with_cause(e)
.into()
2026-02-20 15:36:04 -08:00
})
}
2026-02-22 00:08:02 -08:00
/// 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>,
}
2026-02-20 15:36:04 -08:00
2026-02-22 00:08:02 -08:00
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,
2026-02-20 15:36:04 -08:00
}
2026-02-22 00:08:02 -08:00
}
}
2026-02-20 15:36:04 -08:00
2026-02-22 00:08:02 -08:00
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)
}
}
2026-02-20 15:36:04 -08:00
2026-02-22 00:08:02 -08:00
/// 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>,
}
2026-02-20 15:36:04 -08:00
2026-02-22 00:08:02 -08:00
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,
2026-02-20 15:36:04 -08:00
}
2026-02-22 00:08:02 -08:00
}
}
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)
}
}
2026-02-22 00:39:51 -08:00
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `GameTimer`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait game_timerQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `GameTimer`.
fn game_timer(&self) -> __sdk::__query_builder::Table<GameTimer>;
}
impl game_timerQueryTableAccess for __sdk::QueryTableAccessor {
fn game_timer(&self) -> __sdk::__query_builder::Table<GameTimer> {
__sdk::__query_builder::Table::new("game_timer")
}
}