// 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_state_type::GameState; use super::lobby_type::Lobby; use super::player_or_bot_type::PlayerOrBot; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `lobby`. /// /// Obtain a handle from the [`LobbyTableAccess::lobby`] method on [`super::RemoteTables`], /// like `ctx.db.lobby()`. /// /// Users are encouraged not to explicitly reference this type, /// but to directly chain method calls, /// like `ctx.db.lobby().on_insert(...)`. pub struct LobbyTableHandle<'ctx> { imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } #[allow(non_camel_case_types)] /// Extension trait for access to the table `lobby`. /// /// Implemented for [`super::RemoteTables`]. pub trait LobbyTableAccess { #[allow(non_snake_case)] /// Obtain a [`LobbyTableHandle`], which mediates access to the table `lobby`. fn lobby(&self) -> LobbyTableHandle<'_>; } impl LobbyTableAccess for super::RemoteTables { fn lobby(&self) -> LobbyTableHandle<'_> { LobbyTableHandle { imp: self.imp.get_table::("lobby"), ctx: std::marker::PhantomData, } } } pub struct LobbyInsertCallbackId(__sdk::CallbackId); pub struct LobbyDeleteCallbackId(__sdk::CallbackId); impl<'ctx> __sdk::Table for LobbyTableHandle<'ctx> { type Row = Lobby; type EventContext = super::EventContext; fn count(&self) -> u64 { self.imp.count() } fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = LobbyInsertCallbackId; fn on_insert( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, ) -> LobbyInsertCallbackId { LobbyInsertCallbackId(self.imp.on_insert(Box::new(callback))) } fn remove_on_insert(&self, callback: LobbyInsertCallbackId) { self.imp.remove_on_insert(callback.0) } type DeleteCallbackId = LobbyDeleteCallbackId; fn on_delete( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, ) -> LobbyDeleteCallbackId { LobbyDeleteCallbackId(self.imp.on_delete(Box::new(callback))) } fn remove_on_delete(&self, callback: LobbyDeleteCallbackId) { self.imp.remove_on_delete(callback.0) } } #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { let _table = client_cache.get_or_make_table::("lobby"); _table.add_unique_constraint::("id", |row| &row.id); } pub struct LobbyUpdateCallbackId(__sdk::CallbackId); impl<'ctx> __sdk::TableWithPrimaryKey for LobbyTableHandle<'ctx> { type UpdateCallbackId = LobbyUpdateCallbackId; fn on_update( &self, callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, ) -> LobbyUpdateCallbackId { LobbyUpdateCallbackId(self.imp.on_update(Box::new(callback))) } fn remove_on_update(&self, callback: LobbyUpdateCallbackId) { 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> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") .with_cause(e) .into() }) } /// Access to the `id` unique index on the table `lobby`, /// which allows point queries on the field of the same name /// via the [`LobbyIdUnique::find`] method. /// /// Users are encouraged not to explicitly reference this type, /// but to directly chain method calls, /// like `ctx.db.lobby().id().find(...)`. pub struct LobbyIdUnique<'ctx> { imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } impl<'ctx> LobbyTableHandle<'ctx> { /// Get a handle on the `id` unique index on the table `lobby`. pub fn id(&self) -> LobbyIdUnique<'ctx> { LobbyIdUnique { imp: self.imp.get_unique_constraint::("id"), phantom: std::marker::PhantomData, } } } impl<'ctx> LobbyIdUnique<'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 { self.imp.find(col_val) } } #[allow(non_camel_case_types)] /// Extension trait for query builder access to the table `Lobby`. /// /// Implemented for [`__sdk::QueryTableAccessor`]. pub trait lobbyQueryTableAccess { #[allow(non_snake_case)] /// Get a query builder for the table `Lobby`. fn lobby(&self) -> __sdk::__query_builder::Table; } impl lobbyQueryTableAccess for __sdk::QueryTableAccessor { fn lobby(&self) -> __sdk::__query_builder::Table { __sdk::__query_builder::Table::new("lobby") } }