Files
Genarrative/server-rs/crates/spacetime-client/src/module_bindings/asset_event_table.rs

100 lines
3.3 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 super::asset_event_kind_type::AssetEventKind;
use super::asset_event_type::AssetEvent;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `asset_event`.
///
/// Obtain a handle from the [`AssetEventTableAccess::asset_event`] method on [`super::RemoteTables`],
/// like `ctx.db.asset_event()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.asset_event().on_insert(...)`.
pub struct AssetEventTableHandle<'ctx> {
imp: __sdk::TableHandle<AssetEvent>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `asset_event`.
///
/// Implemented for [`super::RemoteTables`].
pub trait AssetEventTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`AssetEventTableHandle`], which mediates access to the table `asset_event`.
fn asset_event(&self) -> AssetEventTableHandle<'_>;
}
impl AssetEventTableAccess for super::RemoteTables {
fn asset_event(&self) -> AssetEventTableHandle<'_> {
AssetEventTableHandle {
imp: self.imp.get_table::<AssetEvent>("asset_event"),
ctx: std::marker::PhantomData,
}
}
}
pub struct AssetEventInsertCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::EventTable for AssetEventTableHandle<'ctx> {
type Row = AssetEvent;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = AssetEvent> + '_ {
self.imp.iter()
}
type InsertCallbackId = AssetEventInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> AssetEventInsertCallbackId {
AssetEventInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: AssetEventInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<AssetEvent>("asset_event");
_table.add_unique_constraint::<String>("event_id", |row| &row.event_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<AssetEvent>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<AssetEvent>", "TableUpdate")
.with_cause(e)
.into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `AssetEvent`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait asset_eventQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `AssetEvent`.
fn asset_event(&self) -> __sdk::__query_builder::Table<AssetEvent>;
}
impl asset_eventQueryTableAccess for __sdk::QueryTableAccessor {
fn asset_event(&self) -> __sdk::__query_builder::Table<AssetEvent> {
__sdk::__query_builder::Table::new("asset_event")
}
}