// 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::npc_relation_state_type::NpcRelationState; use super::npc_stance_profile_type::NpcStanceProfile; use super::npc_state_type::NpcState; use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; /// Table handle for the table `npc_state`. /// /// Obtain a handle from the [`NpcStateTableAccess::npc_state`] method on [`super::RemoteTables`], /// like `ctx.db.npc_state()`. /// /// Users are encouraged not to explicitly reference this type, /// but to directly chain method calls, /// like `ctx.db.npc_state().on_insert(...)`. pub struct NpcStateTableHandle<'ctx> { imp: __sdk::TableHandle, ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, } #[allow(non_camel_case_types)] /// Extension trait for access to the table `npc_state`. /// /// Implemented for [`super::RemoteTables`]. pub trait NpcStateTableAccess { #[allow(non_snake_case)] /// Obtain a [`NpcStateTableHandle`], which mediates access to the table `npc_state`. fn npc_state(&self) -> NpcStateTableHandle<'_>; } impl NpcStateTableAccess for super::RemoteTables { fn npc_state(&self) -> NpcStateTableHandle<'_> { NpcStateTableHandle { imp: self.imp.get_table::("npc_state"), ctx: std::marker::PhantomData, } } } pub struct NpcStateInsertCallbackId(__sdk::CallbackId); pub struct NpcStateDeleteCallbackId(__sdk::CallbackId); impl<'ctx> __sdk::Table for NpcStateTableHandle<'ctx> { type Row = NpcState; type EventContext = super::EventContext; fn count(&self) -> u64 { self.imp.count() } fn iter(&self) -> impl Iterator + '_ { self.imp.iter() } type InsertCallbackId = NpcStateInsertCallbackId; fn on_insert( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, ) -> NpcStateInsertCallbackId { NpcStateInsertCallbackId(self.imp.on_insert(Box::new(callback))) } fn remove_on_insert(&self, callback: NpcStateInsertCallbackId) { self.imp.remove_on_insert(callback.0) } type DeleteCallbackId = NpcStateDeleteCallbackId; fn on_delete( &self, callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, ) -> NpcStateDeleteCallbackId { NpcStateDeleteCallbackId(self.imp.on_delete(Box::new(callback))) } fn remove_on_delete(&self, callback: NpcStateDeleteCallbackId) { self.imp.remove_on_delete(callback.0) } } pub struct NpcStateUpdateCallbackId(__sdk::CallbackId); impl<'ctx> __sdk::TableWithPrimaryKey for NpcStateTableHandle<'ctx> { type UpdateCallbackId = NpcStateUpdateCallbackId; fn on_update( &self, callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, ) -> NpcStateUpdateCallbackId { NpcStateUpdateCallbackId(self.imp.on_update(Box::new(callback))) } fn remove_on_update(&self, callback: NpcStateUpdateCallbackId) { self.imp.remove_on_update(callback.0) } } /// Access to the `npc_state_id` unique index on the table `npc_state`, /// which allows point queries on the field of the same name /// via the [`NpcStateNpcStateIdUnique::find`] method. /// /// Users are encouraged not to explicitly reference this type, /// but to directly chain method calls, /// like `ctx.db.npc_state().npc_state_id().find(...)`. pub struct NpcStateNpcStateIdUnique<'ctx> { imp: __sdk::UniqueConstraintHandle, phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, } impl<'ctx> NpcStateTableHandle<'ctx> { /// Get a handle on the `npc_state_id` unique index on the table `npc_state`. pub fn npc_state_id(&self) -> NpcStateNpcStateIdUnique<'ctx> { NpcStateNpcStateIdUnique { imp: self.imp.get_unique_constraint::("npc_state_id"), phantom: std::marker::PhantomData, } } } impl<'ctx> NpcStateNpcStateIdUnique<'ctx> { /// Find the subscribed row whose `npc_state_id` column value is equal to `col_val`, /// if such a row is present in the client cache. pub fn find(&self, col_val: &String) -> Option { self.imp.find(col_val) } } #[doc(hidden)] pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { let _table = client_cache.get_or_make_table::("npc_state"); _table.add_unique_constraint::("npc_state_id", |row| &row.npc_state_id); } #[doc(hidden)] pub(super) fn parse_table_update( raw_updates: __ws::v2::TableUpdate, ) -> __sdk::Result<__sdk::TableUpdate> { __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") .with_cause(e) .into() }) } #[allow(non_camel_case_types)] /// Extension trait for query builder access to the table `NpcState`. /// /// Implemented for [`__sdk::QueryTableAccessor`]. pub trait npc_stateQueryTableAccess { #[allow(non_snake_case)] /// Get a query builder for the table `NpcState`. fn npc_state(&self) -> __sdk::__query_builder::Table; } impl npc_stateQueryTableAccess for __sdk::QueryTableAccessor { fn npc_state(&self) -> __sdk::__query_builder::Table { __sdk::__query_builder::Table::new("npc_state") } }