@@ -93,8 +93,14 @@ pub fn expand_service_macro(input_fn: ItemFn) -> Result<TokenStream> {
9393
9494 /// Spawn this service on Embassy runtime (requires static task definition)
9595 ///
96- /// This is a placeholder - actual Embassy spawning happens through
97- /// macro-generated #[embassy_executor::task] functions.
96+ /// This spawns the service as an Embassy task, using the spawner contained
97+ /// within the adapter. The adapter must have been created with a spawner.
98+ ///
99+ /// # Arguments
100+ /// * `adapter` - A static reference to the Embassy adapter with spawner
101+ ///
102+ /// # Returns
103+ /// Ok(()) if spawning succeeded, or an error if the spawner is unavailable
98104 #[ cfg( feature = "embassy-runtime" ) ]
99105 pub fn spawn_embassy(
100106 adapter: & ' static aimdb_embassy_adapter:: EmbassyAdapter ,
@@ -126,11 +132,13 @@ pub fn expand_service_macro(input_fn: ItemFn) -> Result<TokenStream> {
126132
127133 // Embassy task wrapper (only with embassy-runtime feature)
128134 // Each service gets a unique task wrapper name to avoid conflicts
129- // The adapter is passed as a reference since RuntimeContext::new() in no_std
130- // requires a 'static reference
135+ // The adapter must be a 'static reference because Embassy tasks require 'static lifetime
136+ // and RuntimeContext in no_std mode requires a 'static reference to the runtime
131137 #[ cfg( feature = "embassy-runtime" ) ]
132138 #[ embassy_executor:: task]
133139 async fn #embassy_task_name( adapter: & ' static aimdb_embassy_adapter:: EmbassyAdapter ) {
140+ // In no_std/embassy mode, RuntimeContext::new() expects &'static R
141+ // This is correct - Embassy adapter is passed as &'static
134142 let ctx = aimdb_core:: RuntimeContext :: new( adapter) ;
135143 let _ = #fn_name( ctx) . await ;
136144 }
0 commit comments