Files
mize/packages/generated/src/spacetime/log_events_table.rs

161 lines
5.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::action_type::Action;
use super::log_event_type::LogEvent;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `log_events`.
///
/// Obtain a handle from the [`LogEventsTableAccess::log_events`] method on [`super::RemoteTables`],
/// like `ctx.db.log_events()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.log_events().on_insert(...)`.
pub struct LogEventsTableHandle<'ctx> {
imp: __sdk::TableHandle<LogEvent>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `log_events`.
///
/// Implemented for [`super::RemoteTables`].
pub trait LogEventsTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`LogEventsTableHandle`], which mediates access to the table `log_events`.
fn log_events(&self) -> LogEventsTableHandle<'_>;
}
impl LogEventsTableAccess for super::RemoteTables {
fn log_events(&self) -> LogEventsTableHandle<'_> {
LogEventsTableHandle {
imp: self.imp.get_table::<LogEvent>("log_events"),
ctx: std::marker::PhantomData,
}
}
}
pub struct LogEventsInsertCallbackId(__sdk::CallbackId);
pub struct LogEventsDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for LogEventsTableHandle<'ctx> {
type Row = LogEvent;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = LogEvent> + '_ {
self.imp.iter()
}
type InsertCallbackId = LogEventsInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> LogEventsInsertCallbackId {
LogEventsInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: LogEventsInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = LogEventsDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> LogEventsDeleteCallbackId {
LogEventsDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: LogEventsDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct LogEventsUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for LogEventsTableHandle<'ctx> {
type UpdateCallbackId = LogEventsUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> LogEventsUpdateCallbackId {
LogEventsUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: LogEventsUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `id` unique index on the table `log_events`,
/// which allows point queries on the field of the same name
/// via the [`LogEventsIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.log_events().id().find(...)`.
pub struct LogEventsIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<LogEvent, u64>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> LogEventsTableHandle<'ctx> {
/// Get a handle on the `id` unique index on the table `log_events`.
pub fn id(&self) -> LogEventsIdUnique<'ctx> {
LogEventsIdUnique {
imp: self.imp.get_unique_constraint::<u64>("id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> LogEventsIdUnique<'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<LogEvent> {
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::<LogEvent>("log_events");
_table.add_unique_constraint::<u64>("id", |row| &row.id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<LogEvent>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<LogEvent>", "TableUpdate")
.with_cause(e)
.into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `LogEvent`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait log_eventsQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `LogEvent`.
fn log_events(&self) -> __sdk::__query_builder::Table<LogEvent>;
}
impl log_eventsQueryTableAccess for __sdk::QueryTableAccessor {
fn log_events(&self) -> __sdk::__query_builder::Table<LogEvent> {
__sdk::__query_builder::Table::new("log_events")
}
}