Files
mize/packages/ppc/generated/task_part_table.rs
2026-04-02 17:18:23 +02:00

163 lines
5.4 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::activity_type::Activity;
use super::task_part_type::TaskPart;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `task_part`.
///
/// Obtain a handle from the [`TaskPartTableAccess::task_part`] method on [`super::RemoteTables`],
/// like `ctx.db.task_part()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.task_part().on_insert(...)`.
pub struct TaskPartTableHandle<'ctx> {
imp: __sdk::TableHandle<TaskPart>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `task_part`.
///
/// Implemented for [`super::RemoteTables`].
pub trait TaskPartTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`TaskPartTableHandle`], which mediates access to the table `task_part`.
fn task_part(&self) -> TaskPartTableHandle<'_>;
}
impl TaskPartTableAccess for super::RemoteTables {
fn task_part(&self) -> TaskPartTableHandle<'_> {
TaskPartTableHandle {
imp: self.imp.get_table::<TaskPart>("task_part"),
ctx: std::marker::PhantomData,
}
}
}
pub struct TaskPartInsertCallbackId(__sdk::CallbackId);
pub struct TaskPartDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for TaskPartTableHandle<'ctx> {
type Row = TaskPart;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = TaskPart> + '_ {
self.imp.iter()
}
type InsertCallbackId = TaskPartInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> TaskPartInsertCallbackId {
TaskPartInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: TaskPartInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = TaskPartDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> TaskPartDeleteCallbackId {
TaskPartDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: TaskPartDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct TaskPartUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for TaskPartTableHandle<'ctx> {
type UpdateCallbackId = TaskPartUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> TaskPartUpdateCallbackId {
TaskPartUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: TaskPartUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `identity` unique index on the table `task_part`,
/// which allows point queries on the field of the same name
/// via the [`TaskPartIdentityUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.task_part().identity().find(...)`.
pub struct TaskPartIdentityUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<TaskPart, __sdk::Identity>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> TaskPartTableHandle<'ctx> {
/// Get a handle on the `identity` unique index on the table `task_part`.
pub fn identity(&self) -> TaskPartIdentityUnique<'ctx> {
TaskPartIdentityUnique {
imp: self
.imp
.get_unique_constraint::<__sdk::Identity>("identity"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> TaskPartIdentityUnique<'ctx> {
/// Find the subscribed row whose `identity` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &__sdk::Identity) -> Option<TaskPart> {
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::<TaskPart>("task_part");
_table.add_unique_constraint::<__sdk::Identity>("identity", |row| &row.identity);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<TaskPart>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<TaskPart>", "TableUpdate")
.with_cause(e)
.into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `TaskPart`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait task_partQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `TaskPart`.
fn task_part(&self) -> __sdk::__query_builder::Table<TaskPart>;
}
impl task_partQueryTableAccess for __sdk::QueryTableAccessor {
fn task_part(&self) -> __sdk::__query_builder::Table<TaskPart> {
__sdk::__query_builder::Table::new("task_part")
}
}