The [`Table`] and [`TableWithPrimaryKey`] traits, which allow certain simple queries of the client cache, and expose row callbacks which run when subscribed rows are inserted, deleted or updated. These traits are implemented by "table handles," types generated by the SpacetimeDB CLI's module-specific codegen which mediate access to tables in the client cache. Obtain a table handle by calling a me
| 13 | /// |
| 14 | /// For persistent (non-event) tables only. See [`EventTable`] for transient event tables. |
| 15 | pub trait Table { |
| 16 | /// The type of rows stored in this table. |
| 17 | type Row: 'static; |
| 18 | |
| 19 | /// The `EventContext` type generated for the module which defines this table. |
| 20 | type EventContext; |
| 21 | |
| 22 | /// The number of subscribed rows in the client cache. |
| 23 | fn count(&self) -> u64; |
| 24 | |
| 25 | /// An iterator over all the subscribed rows in the client cache. |
| 26 | fn iter(&self) -> impl Iterator<Item = Self::Row> + '_; |
| 27 | |
| 28 | type InsertCallbackId; |
| 29 | /// Register a callback to run whenever a subscribed row is inserted into the client cache. |
| 30 | /// |
| 31 | /// The returned [`Self::InsertCallbackId`] can be passed to [`Self::remove_on_insert`] |
| 32 | /// to cancel the callback. |
| 33 | fn on_insert( |
| 34 | &self, |
| 35 | callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, |
| 36 | ) -> Self::InsertCallbackId; |
| 37 | /// Cancel a callback previously registered by [`Self::on_insert`], causing it not to run in the future. |
| 38 | fn remove_on_insert(&self, callback: Self::InsertCallbackId); |
| 39 | |
| 40 | type DeleteCallbackId; |
| 41 | /// Register a callback to run whenever a subscribed row is deleted from the client cache. |
| 42 | /// |
| 43 | /// The returned [`Self::DeleteCallbackId`] can be passed to [`Self::remove_on_delete`] |
| 44 | /// to cancel the callback. |
| 45 | fn on_delete( |
| 46 | &self, |
| 47 | callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static, |
| 48 | ) -> Self::DeleteCallbackId; |
| 49 | /// Cancel a callback previously registered by [`Self::on_delete`], causing it not to run in the future. |
| 50 | fn remove_on_delete(&self, callback: Self::DeleteCallbackId); |
| 51 | } |
| 52 | |
| 53 | /// Subtrait of [`Table`] implemented only by tables with a column designated as a primary key, |
| 54 | /// which allows the SDK to identify updates. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…