Skip to main content

delegate

Attribute Macro delegate 

Source
#[delegate]
Expand description

Generate the necessary code for the WASM runtime to interact with your delegate ergonomically and safely.

§Declaring a manifest

A delegate that wants lifecycle events or node-enforced capabilities declares them, and the macro embeds a manifest in the WASM (see freenet_stdlib::prelude::DelegateManifest):

ⓘ
#[delegate(manifest(lifecycle = [Installed, NodeStarted], capabilities = [Background]))]
impl DelegateInterface for MyDelegate { /* ... */ }

Without manifest(...) nothing is embedded and the delegate behaves as delegates always have. Adding one changes the WASM, and so the delegate key.

Listing any lifecycle kind requires capabilities = [Background]. Only one manifest per crate: the section is per WASM module. Custom sections must survive any post-processing of the module (wasm-opt --strip-*, wasm-strip remove them); a missing section means “no manifest”, silently.