diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs new file mode 100644 index 0000000000..124f51162f --- /dev/null +++ b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs @@ -0,0 +1,46 @@ +// 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::scheduled_proc_table_type::ScheduledProcTable; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +struct ScheduledProcArgs { + pub data: ScheduledProcTable, +} + +impl __sdk::InModule for ScheduledProcArgs { + type Module = super::RemoteModule; +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the procedure `scheduled_proc`. +/// +/// Implemented for [`super::RemoteProcedures`]. +pub trait scheduled_proc { + fn scheduled_proc(&self, data: ScheduledProcTable) { + self.scheduled_proc_then(data, |_, _| {}); + } + + fn scheduled_proc_then( + &self, + data: ScheduledProcTable, + + __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, + ); +} + +impl scheduled_proc for super::RemoteProcedures { + fn scheduled_proc_then( + &self, + data: ScheduledProcTable, + + __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, + ) { + self.imp + .invoke_procedure_with_callback::<_, ()>("scheduled_proc", ScheduledProcArgs { data }, __callback); + } +} diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_table_table.rs b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_table_table.rs new file mode 100644 index 0000000000..df40081221 --- /dev/null +++ b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_table_table.rs @@ -0,0 +1,158 @@ +// 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::scheduled_proc_table_type::ScheduledProcTable; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `scheduled_proc_table`. +/// +/// Obtain a handle from the [`ScheduledProcTableTableAccess::scheduled_proc_table`] method on [`super::RemoteTables`], +/// like `ctx.db.scheduled_proc_table()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.scheduled_proc_table().on_insert(...)`. +pub struct ScheduledProcTableTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `scheduled_proc_table`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait ScheduledProcTableTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`ScheduledProcTableTableHandle`], which mediates access to the table `scheduled_proc_table`. + fn scheduled_proc_table(&self) -> ScheduledProcTableTableHandle<'_>; +} + +impl ScheduledProcTableTableAccess for super::RemoteTables { + fn scheduled_proc_table(&self) -> ScheduledProcTableTableHandle<'_> { + ScheduledProcTableTableHandle { + imp: self.imp.get_table::("scheduled_proc_table"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct ScheduledProcTableInsertCallbackId(__sdk::CallbackId); +pub struct ScheduledProcTableDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for ScheduledProcTableTableHandle<'ctx> { + type Row = ScheduledProcTable; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = ScheduledProcTableInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ScheduledProcTableInsertCallbackId { + ScheduledProcTableInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: ScheduledProcTableInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = ScheduledProcTableDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> ScheduledProcTableDeleteCallbackId { + ScheduledProcTableDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: ScheduledProcTableDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("scheduled_proc_table"); + _table.add_unique_constraint::("scheduled_id", |row| &row.scheduled_id); +} +pub struct ScheduledProcTableUpdateCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::TableWithPrimaryKey for ScheduledProcTableTableHandle<'ctx> { + type UpdateCallbackId = ScheduledProcTableUpdateCallbackId; + + fn on_update( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static, + ) -> ScheduledProcTableUpdateCallbackId { + ScheduledProcTableUpdateCallbackId(self.imp.on_update(Box::new(callback))) + } + + fn remove_on_update(&self, callback: ScheduledProcTableUpdateCallbackId) { + self.imp.remove_on_update(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::v2::TableUpdate, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() + }) +} + +/// Access to the `scheduled_id` unique index on the table `scheduled_proc_table`, +/// which allows point queries on the field of the same name +/// via the [`ScheduledProcTableScheduledIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.scheduled_proc_table().scheduled_id().find(...)`. +pub struct ScheduledProcTableScheduledIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +impl<'ctx> ScheduledProcTableTableHandle<'ctx> { + /// Get a handle on the `scheduled_id` unique index on the table `scheduled_proc_table`. + pub fn scheduled_id(&self) -> ScheduledProcTableScheduledIdUnique<'ctx> { + ScheduledProcTableScheduledIdUnique { + imp: self.imp.get_unique_constraint::("scheduled_id"), + phantom: std::marker::PhantomData, + } + } +} + +impl<'ctx> ScheduledProcTableScheduledIdUnique<'ctx> { + /// Find the subscribed row whose `scheduled_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 { + self.imp.find(col_val) + } +} + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `ScheduledProcTable`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait scheduled_proc_tableQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `ScheduledProcTable`. + fn scheduled_proc_table(&self) -> __sdk::__query_builder::Table; +} + +impl scheduled_proc_tableQueryTableAccess for __sdk::QueryTableAccessor { + fn scheduled_proc_table(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("scheduled_proc_table") + } +} diff --git a/sdks/rust/tests/test-client/src/module_bindings/indexed_table_2_table.rs b/sdks/rust/tests/test-client/src/module_bindings/indexed_table_2_table.rs new file mode 100644 index 0000000000..63eaf2e6ff --- /dev/null +++ b/sdks/rust/tests/test-client/src/module_bindings/indexed_table_2_table.rs @@ -0,0 +1,111 @@ +// 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::indexed_table_2_type::IndexedTable2; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `indexed_table_2`. +/// +/// Obtain a handle from the [`IndexedTable2TableAccess::indexed_table_2`] method on [`super::RemoteTables`], +/// like `ctx.db.indexed_table_2()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.indexed_table_2().on_insert(...)`. +pub struct IndexedTable2TableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `indexed_table_2`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait IndexedTable2TableAccess { + #[allow(non_snake_case)] + /// Obtain a [`IndexedTable2TableHandle`], which mediates access to the table `indexed_table_2`. + fn indexed_table_2(&self) -> IndexedTable2TableHandle<'_>; +} + +impl IndexedTable2TableAccess for super::RemoteTables { + fn indexed_table_2(&self) -> IndexedTable2TableHandle<'_> { + IndexedTable2TableHandle { + imp: self.imp.get_table::("indexed_table_2"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct IndexedTable2InsertCallbackId(__sdk::CallbackId); +pub struct IndexedTable2DeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for IndexedTable2TableHandle<'ctx> { + type Row = IndexedTable2; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = IndexedTable2InsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTable2InsertCallbackId { + IndexedTable2InsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: IndexedTable2InsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = IndexedTable2DeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTable2DeleteCallbackId { + IndexedTable2DeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: IndexedTable2DeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("indexed_table_2"); +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::v2::TableUpdate, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() + }) +} + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `IndexedTable2`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait indexed_table_2QueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `IndexedTable2`. + fn indexed_table_2(&self) -> __sdk::__query_builder::Table; +} + +impl indexed_table_2QueryTableAccess for __sdk::QueryTableAccessor { + fn indexed_table_2(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("indexed_table_2") + } +} diff --git a/sdks/rust/tests/test-client/src/module_bindings/indexed_table_table.rs b/sdks/rust/tests/test-client/src/module_bindings/indexed_table_table.rs new file mode 100644 index 0000000000..73b03043ac --- /dev/null +++ b/sdks/rust/tests/test-client/src/module_bindings/indexed_table_table.rs @@ -0,0 +1,111 @@ +// 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::indexed_table_type::IndexedTable; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `indexed_table`. +/// +/// Obtain a handle from the [`IndexedTableTableAccess::indexed_table`] method on [`super::RemoteTables`], +/// like `ctx.db.indexed_table()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.indexed_table().on_insert(...)`. +pub struct IndexedTableTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `indexed_table`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait IndexedTableTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`IndexedTableTableHandle`], which mediates access to the table `indexed_table`. + fn indexed_table(&self) -> IndexedTableTableHandle<'_>; +} + +impl IndexedTableTableAccess for super::RemoteTables { + fn indexed_table(&self) -> IndexedTableTableHandle<'_> { + IndexedTableTableHandle { + imp: self.imp.get_table::("indexed_table"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct IndexedTableInsertCallbackId(__sdk::CallbackId); +pub struct IndexedTableDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for IndexedTableTableHandle<'ctx> { + type Row = IndexedTable; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = IndexedTableInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTableInsertCallbackId { + IndexedTableInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: IndexedTableInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = IndexedTableDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> IndexedTableDeleteCallbackId { + IndexedTableDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: IndexedTableDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("indexed_table"); +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::v2::TableUpdate, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() + }) +} + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `IndexedTable`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait indexed_tableQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `IndexedTable`. + fn indexed_table(&self) -> __sdk::__query_builder::Table; +} + +impl indexed_tableQueryTableAccess for __sdk::QueryTableAccessor { + fn indexed_table(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("indexed_table") + } +} diff --git a/sdks/rust/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs b/sdks/rust/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs new file mode 100644 index 0000000000..2c6a5d14ef --- /dev/null +++ b/sdks/rust/tests/test-client/src/module_bindings/send_scheduled_message_reducer.rs @@ -0,0 +1,68 @@ +// 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::scheduled_table_type::ScheduledTable; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub(super) struct SendScheduledMessageArgs { + pub arg: ScheduledTable, +} + +impl From for super::Reducer { + fn from(args: SendScheduledMessageArgs) -> Self { + Self::SendScheduledMessage { arg: args.arg } + } +} + +impl __sdk::InModule for SendScheduledMessageArgs { + type Module = super::RemoteModule; +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the reducer `send_scheduled_message`. +/// +/// Implemented for [`super::RemoteReducers`]. +pub trait send_scheduled_message { + /// Request that the remote module invoke the reducer `send_scheduled_message` to run as soon as possible. + /// + /// This method returns immediately, and errors only if we are unable to send the request. + /// The reducer will run asynchronously in the future, + /// and this method provides no way to listen for its completion status. + /// /// Use [`send_scheduled_message:send_scheduled_message_then`] to run a callback after the reducer completes. + fn send_scheduled_message(&self, arg: ScheduledTable) -> __sdk::Result<()> { + self.send_scheduled_message_then(arg, |_, _| {}) + } + + /// Request that the remote module invoke the reducer `send_scheduled_message` to run as soon as possible, + /// registering `callback` to run when we are notified that the reducer completed. + /// + /// This method returns immediately, and errors only if we are unable to send the request. + /// The reducer will run asynchronously in the future, + /// and its status can be observed with the `callback`. + fn send_scheduled_message_then( + &self, + arg: ScheduledTable, + + callback: impl FnOnce(&super::ReducerEventContext, Result, __sdk::InternalError>) + + Send + + 'static, + ) -> __sdk::Result<()>; +} + +impl send_scheduled_message for super::RemoteReducers { + fn send_scheduled_message_then( + &self, + arg: ScheduledTable, + + callback: impl FnOnce(&super::ReducerEventContext, Result, __sdk::InternalError>) + + Send + + 'static, + ) -> __sdk::Result<()> { + self.imp + .invoke_reducer_with_callback(SendScheduledMessageArgs { arg }, callback) + } +} diff --git a/sdks/rust/tests/view-client/src/module_bindings/player_location_table.rs b/sdks/rust/tests/view-client/src/module_bindings/player_location_table.rs new file mode 100644 index 0000000000..efe15384b4 --- /dev/null +++ b/sdks/rust/tests/view-client/src/module_bindings/player_location_table.rs @@ -0,0 +1,142 @@ +// 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::player_location_type::PlayerLocation; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +/// Table handle for the table `player_location`. +/// +/// Obtain a handle from the [`PlayerLocationTableAccess::player_location`] method on [`super::RemoteTables`], +/// like `ctx.db.player_location()`. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_location().on_insert(...)`. +pub struct PlayerLocationTableHandle<'ctx> { + imp: __sdk::TableHandle, + ctx: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the table `player_location`. +/// +/// Implemented for [`super::RemoteTables`]. +pub trait PlayerLocationTableAccess { + #[allow(non_snake_case)] + /// Obtain a [`PlayerLocationTableHandle`], which mediates access to the table `player_location`. + fn player_location(&self) -> PlayerLocationTableHandle<'_>; +} + +impl PlayerLocationTableAccess for super::RemoteTables { + fn player_location(&self) -> PlayerLocationTableHandle<'_> { + PlayerLocationTableHandle { + imp: self.imp.get_table::("player_location"), + ctx: std::marker::PhantomData, + } + } +} + +pub struct PlayerLocationInsertCallbackId(__sdk::CallbackId); +pub struct PlayerLocationDeleteCallbackId(__sdk::CallbackId); + +impl<'ctx> __sdk::Table for PlayerLocationTableHandle<'ctx> { + type Row = PlayerLocation; + type EventContext = super::EventContext; + + fn count(&self) -> u64 { + self.imp.count() + } + fn iter(&self) -> impl Iterator + '_ { + self.imp.iter() + } + + type InsertCallbackId = PlayerLocationInsertCallbackId; + + fn on_insert( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerLocationInsertCallbackId { + PlayerLocationInsertCallbackId(self.imp.on_insert(Box::new(callback))) + } + + fn remove_on_insert(&self, callback: PlayerLocationInsertCallbackId) { + self.imp.remove_on_insert(callback.0) + } + + type DeleteCallbackId = PlayerLocationDeleteCallbackId; + + fn on_delete( + &self, + callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, + ) -> PlayerLocationDeleteCallbackId { + PlayerLocationDeleteCallbackId(self.imp.on_delete(Box::new(callback))) + } + + fn remove_on_delete(&self, callback: PlayerLocationDeleteCallbackId) { + self.imp.remove_on_delete(callback.0) + } +} + +#[doc(hidden)] +pub(super) fn register_table(client_cache: &mut __sdk::ClientCache) { + let _table = client_cache.get_or_make_table::("player_location"); + _table.add_unique_constraint::("entity_id", |row| &row.entity_id); +} + +#[doc(hidden)] +pub(super) fn parse_table_update( + raw_updates: __ws::v2::TableUpdate, +) -> __sdk::Result<__sdk::TableUpdate> { + __sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| { + __sdk::InternalError::failed_parse("TableUpdate", "TableUpdate") + .with_cause(e) + .into() + }) +} + +/// Access to the `entity_id` unique index on the table `player_location`, +/// which allows point queries on the field of the same name +/// via the [`PlayerLocationEntityIdUnique::find`] method. +/// +/// Users are encouraged not to explicitly reference this type, +/// but to directly chain method calls, +/// like `ctx.db.player_location().entity_id().find(...)`. +pub struct PlayerLocationEntityIdUnique<'ctx> { + imp: __sdk::UniqueConstraintHandle, + phantom: std::marker::PhantomData<&'ctx super::RemoteTables>, +} + +impl<'ctx> PlayerLocationTableHandle<'ctx> { + /// Get a handle on the `entity_id` unique index on the table `player_location`. + pub fn entity_id(&self) -> PlayerLocationEntityIdUnique<'ctx> { + PlayerLocationEntityIdUnique { + imp: self.imp.get_unique_constraint::("entity_id"), + phantom: std::marker::PhantomData, + } + } +} + +impl<'ctx> PlayerLocationEntityIdUnique<'ctx> { + /// Find the subscribed row whose `entity_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 { + self.imp.find(col_val) + } +} + +#[allow(non_camel_case_types)] +/// Extension trait for query builder access to the table `PlayerLocation`. +/// +/// Implemented for [`__sdk::QueryTableAccessor`]. +pub trait player_locationQueryTableAccess { + #[allow(non_snake_case)] + /// Get a query builder for the table `PlayerLocation`. + fn player_location(&self) -> __sdk::__query_builder::Table; +} + +impl player_locationQueryTableAccess for __sdk::QueryTableAccessor { + fn player_location(&self) -> __sdk::__query_builder::Table { + __sdk::__query_builder::Table::new("player_location") + } +}