178 lines
6.4 KiB
Rust
178 lines
6.4 KiB
Rust
|
|
// 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,
|
||
|
|
};
|
||
|
|
use super::game_timer_type::GameTimer;
|
||
|
|
|
||
|
|
/// 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;
|
||
|
|
|
||
|
|
fn count(&self) -> u64 { self.imp.count() }
|
||
|
|
fn iter(&self) -> impl Iterator<Item = GameTimer> + '_ { self.imp.iter() }
|
||
|
|
|
||
|
|
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>) {
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
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| {
|
||
|
|
__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>,
|
||
|
|
}
|
||
|
|
|
||
|
|
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> 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)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|