@@ -10,7 +10,6 @@ use super::{scheduler::ScheduleError, AbiCall};
1010use crate :: error:: { DBError , DatastoreError , IndexError , NodesError } ;
1111use spacetimedb_primitives:: errno;
1212use spacetimedb_sats:: typespace:: TypeRefError ;
13- use spacetimedb_schema:: def:: RawModuleDefVersion ;
1413use spacetimedb_table:: table:: UniqueConstraintViolation ;
1514
1615pub const CALL_REDUCER_DUNDER : & str = "__call_reducer__" ;
@@ -21,52 +20,13 @@ pub const CALL_VIEW_DUNDER: &str = "__call_view__";
2120
2221pub const CALL_VIEW_ANON_DUNDER : & str = "__call_view_anon__" ;
2322
24- /// Name of the function that modules export to the host to describe themselves.
25- ///
26- /// Used by module definitions with versions up to
27- /// [`RawModuleDefVersion::V9OrEarlier`].
2823pub const DESCRIBE_MODULE_DUNDER : & str = "__describe_module__" ;
2924
30- /// Versioned variant of [`DESCRIBE_MODULE_DUNDER`] for
31- /// [`RawModuleDefVersion::V10`].
32- pub const DESCRIBE_MODULE_DUNDER_V10 : & str = "__describe_module_v10__" ;
33-
3425/// functions with this prefix run prior to __setup__, initializing global variables and the like
3526pub const PREINIT_DUNDER : & str = "__preinit__" ;
3627/// initializes the user code in the module. fallible
3728pub const SETUP_DUNDER : & str = "__setup__" ;
3829
39- /// Detects the [`RawModuleDefVersion`] of a module by checking for the presence
40- /// of a known describe function export.
41- pub fn detect_raw_def_version < M > ( module : & M ) -> Result < RawModuleDefVersion , module_host_actor:: DescribeError >
42- where
43- M : module_host_actor:: WasmModule ,
44- {
45- if module. get_export ( DESCRIBE_MODULE_DUNDER ) . is_some ( ) {
46- Ok ( RawModuleDefVersion :: V9OrEarlier )
47- } else if module. get_export ( DESCRIBE_MODULE_DUNDER_V10 ) . is_some ( ) {
48- Ok ( RawModuleDefVersion :: V10 )
49- } else {
50- Err ( module_host_actor:: DescribeError :: Signature ( anyhow:: anyhow!(
51- "module does not export a {} or {} function" ,
52- DESCRIBE_MODULE_DUNDER ,
53- DESCRIBE_MODULE_DUNDER_V10
54- ) ) )
55- }
56- }
57- /// Returns the describe dunder symbol for a given module version.
58- pub const fn describe_dunder ( version : RawModuleDefVersion ) -> & ' static str {
59- match version {
60- RawModuleDefVersion :: V9OrEarlier => DESCRIBE_MODULE_DUNDER ,
61- RawModuleDefVersion :: V10 => DESCRIBE_MODULE_DUNDER_V10 ,
62- }
63- }
64-
65- /// Returns all known describe dunder symbols.
66- pub const fn describe_dunders ( ) -> & ' static [ & ' static str ] {
67- & [ DESCRIBE_MODULE_DUNDER , DESCRIBE_MODULE_DUNDER_V10 ]
68- }
69-
7030#[ derive( Debug , Clone ) ]
7131#[ allow( unused) ]
7232pub enum WasmType {
@@ -269,7 +229,7 @@ impl FuncNames {
269229 }
270230 Ok ( ( ) )
271231 }
272- pub fn check_required < F , T > ( raw_def_ver : RawModuleDefVersion , get_export : F ) -> Result < ( ) , ValidationError >
232+ pub fn check_required < F , T > ( get_export : F ) -> Result < ( ) , ValidationError >
273233 where
274234 F : Fn ( & str ) -> Option < T > ,
275235 T : FuncSigLike ,
@@ -283,9 +243,8 @@ impl FuncNames {
283243 let sig = get_func ( CALL_REDUCER_DUNDER ) ?;
284244 Self :: validate_signature ( "call_reducer" , & sig, CALL_REDUCER_DUNDER , CALL_REDUCER_SIG ) ?;
285245
286- let describe_dunder = describe_dunder ( raw_def_ver) ;
287- let sig = get_func ( describe_dunder) ?;
288- Self :: validate_signature ( "describe_module" , & sig, describe_dunder, DESCRIBE_MODULE_SIG ) ?;
246+ let sig = get_func ( DESCRIBE_MODULE_DUNDER ) ?;
247+ Self :: validate_signature ( "describe_module" , & sig, DESCRIBE_MODULE_DUNDER , DESCRIBE_MODULE_SIG ) ?;
289248
290249 Ok ( ( ) )
291250 }
0 commit comments