Skip to main content

entry

Macro entry 

Source
macro_rules! entry {
    ($workload_type:ty) => { ... };
    ($workload_type:ty, $init_expr:expr) => { ... };
}
Expand description

Generate Component Model exports for a Workload type.

Platform ABI is auto-selected by target:

  • #[cfg(all(target_arch = "wasm32", not(feature = "web")))] — expands to an impl Guest for __ActrEntryAdapter { ... } bridging the user’s Workload into the actr:workload/workload export contract. The runtime calls Dispatcher::dispatch through the dispatch export and every observation hook through its matching WIT export.
  • #[cfg(all(target_arch = "wasm32", feature = "web"))] — expands to a #[wasm_bindgen(start)] bootstrap that wraps the user workload in a WebWorkloadAdapter and calls actr_web_abi::host::register_workload. Only the 17 #[wasm_bindgen] entry points generated inside actr-web-abi::host are exported to the Service Worker host.
  • #[cfg(feature = "cdylib")] — expands to the legacy actr_init / actr_handle / actr_free_response C-ABI exports used by native shared-library hosts.

§Arguments

  • $workload_type: type implementing actr_framework::Workload + Send + Sync + 'static.
  • $init_expr (optional): expression returning a fresh instance of $workload_type. Defaults to <$workload_type as Default>::default().

§Usage

use actr_framework::entry;

entry!(EchoServiceWorkload<MyService>);

// Or with a custom constructor:
entry!(
    EchoServiceWorkload<MyService>,
    EchoServiceWorkload::new(MyService::new())
);