gstd_codegen

Attribute Macro async_init

Source
#[async_init]
Expand description

Mark async function to be the program initialization method.

Can be used together with async_main.

The init function cannot be specified if this macro is used. If you need to specify the init function explicitly, don’t use this macro.

§Examples

Simple async init function:

#[gstd::async_init]
async fn init() {
    gstd::debug!("Hello world!");
}

Use handle_reply and handle_signal parameters to specify corresponding handlers. Note that custom reply and signal handlers derive their default behavior.

#[gstd::async_init(handle_signal = my_handle_signal)]
async fn init() {
    // ...
}

fn my_handle_signal() {
    // ...
}