MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / implement_query_table_accessor

Function implement_query_table_accessor

crates/codegen/src/rust.rs:792–818  ·  view source on GitHub ↗
(table: &TableDef, out: &mut impl Write, struct_name: &String)

Source from the content-addressed store, hash-verified

790}
791
792pub fn implement_query_table_accessor(table: &TableDef, out: &mut impl Write, struct_name: &String) -> fmt::Result {
793 // NEW: Generate query table accessor trait and implementation
794 let accessor_method = table_method_name(&table.accessor_name);
795 let table_name = table.name.deref();
796 let query_accessor_trait = accessor_method.to_string() + "QueryTableAccess";
797
798 writeln!(
799 out,
800 "
801 #[allow(non_camel_case_types)]
802 /// Extension trait for query builder access to the table `{struct_name}`.
803 ///
804 /// Implemented for [`__sdk::QueryTableAccessor`].
805 pub trait {query_accessor_trait} {{
806 #[allow(non_snake_case)]
807 /// Get a query builder for the table `{struct_name}`.
808 fn {accessor_method}(&self) -> __sdk::__query_builder::Table<{struct_name}>;
809 }}
810
811 impl {query_accessor_trait} for __sdk::QueryTableAccessor {{
812 fn {accessor_method}(&self) -> __sdk::__query_builder::Table<{struct_name}> {{
813 __sdk::__query_builder::Table::new({table_name:?})
814 }}
815 }}
816"
817 )
818}
819
820pub fn write_type<W: Write>(module: &ModuleDef, out: &mut W, ty: &AlgebraicTypeUse) -> fmt::Result {
821 match ty {

Callers 1

Calls 3

table_method_nameFunction · 0.85
derefMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…