#[api_def]Expand description
Define an AxVisor API interface.
This attribute macro is applied to a trait definition to register it as an AxVisor API interface. It generates caller functions for each method in the trait, allowing the API to be called as regular functions.
§Usage
ⓘ
use axvisor_api::api_def;
#[api_def]
pub trait MyApiIf {
/// Get a value.
fn get_value() -> u32;
/// Set a value.
fn set_value(value: u32);
}
// After the macro expansion, you can call:
// my_module::get_value()
// my_module::set_value(42)§Generated Code
The macro generates:
- The original trait definition with
crate_interface::def_interfaceattribute. - Free-standing caller functions for each trait method at the same module level.
§Attributes
This macro does not accept any arguments.
§Implementation
This macro uses crate_interface::def_interface internally with the
gen_caller option to generate the caller functions.