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