Files
Genarrative/server-rs/crates/spacetime-client/src/module_bindings/quest_log_table.rs
2026-04-24 12:21:33 +08:00

168 lines
5.8 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::quest_log_type::QuestLog;
use super::quest_status_type::QuestStatus;
use super::quest_progress_signal_type::QuestProgressSignal;
use super::quest_log_event_kind_type::QuestLogEventKind;
use super::quest_signal_kind_type::QuestSignalKind;
/// Table handle for the table `quest_log`.
///
/// Obtain a handle from the [`QuestLogTableAccess::quest_log`] method on [`super::RemoteTables`],
/// like `ctx.db.quest_log()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.quest_log().on_insert(...)`.
pub struct QuestLogTableHandle<'ctx> {
imp: __sdk::TableHandle<QuestLog>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `quest_log`.
///
/// Implemented for [`super::RemoteTables`].
pub trait QuestLogTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`QuestLogTableHandle`], which mediates access to the table `quest_log`.
fn quest_log(&self) -> QuestLogTableHandle<'_>;
}
impl QuestLogTableAccess for super::RemoteTables {
fn quest_log(&self) -> QuestLogTableHandle<'_> {
QuestLogTableHandle {
imp: self.imp.get_table::<QuestLog>("quest_log"),
ctx: std::marker::PhantomData,
}
}
}
pub struct QuestLogInsertCallbackId(__sdk::CallbackId);
pub struct QuestLogDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for QuestLogTableHandle<'ctx> {
type Row = QuestLog;
type EventContext = super::EventContext;
fn count(&self) -> u64 { self.imp.count() }
fn iter(&self) -> impl Iterator<Item = QuestLog> + '_ { self.imp.iter() }
type InsertCallbackId = QuestLogInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> QuestLogInsertCallbackId {
QuestLogInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: QuestLogInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = QuestLogDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> QuestLogDeleteCallbackId {
QuestLogDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: QuestLogDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct QuestLogUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for QuestLogTableHandle<'ctx> {
type UpdateCallbackId = QuestLogUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> QuestLogUpdateCallbackId {
QuestLogUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: QuestLogUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `log_id` unique index on the table `quest_log`,
/// which allows point queries on the field of the same name
/// via the [`QuestLogLogIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.quest_log().log_id().find(...)`.
pub struct QuestLogLogIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<QuestLog, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> QuestLogTableHandle<'ctx> {
/// Get a handle on the `log_id` unique index on the table `quest_log`.
pub fn log_id(&self) -> QuestLogLogIdUnique<'ctx> {
QuestLogLogIdUnique {
imp: self.imp.get_unique_constraint::<String>("log_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> QuestLogLogIdUnique<'ctx> {
/// Find the subscribed row whose `log_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<QuestLog> {
self.imp.find(col_val)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<QuestLog>("quest_log");
_table.add_unique_constraint::<String>("log_id", |row| &row.log_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<QuestLog>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse(
"TableUpdate<QuestLog>",
"TableUpdate",
).with_cause(e).into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `QuestLog`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait quest_logQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `QuestLog`.
fn quest_log(&self) -> __sdk::__query_builder::Table<QuestLog>;
}
impl quest_logQueryTableAccess for __sdk::QueryTableAccessor {
fn quest_log(&self) -> __sdk::__query_builder::Table<QuestLog> {
__sdk::__query_builder::Table::new("quest_log")
}
}