Skip to main content

Crate axvisor_api_proc

Crate axvisor_api_proc 

Source
Expand description

Procedural macros for the axvisor_api crate.

This crate provides the procedural macros used to define and implement AxVisor API interfaces. These macros are built on top of the crate_interface crate and provide a convenient way to create link-time-resolved API interfaces.

§Macros

  • api_def - Define an API interface trait.
  • api_impl - Implement an API interface.

§Usage

This crate is re-exported by axvisor_api and should not be used directly. Instead, use the macros through axvisor_api:

use axvisor_api::{api_def, api_impl};

#[api_def]
pub trait MyApiIf {
    fn my_function() -> u32;
}

struct MyApiImpl;

#[api_impl]
impl MyApiIf for MyApiImpl {
    fn my_function() -> u32 {
        42
    }
}

§How It Works

The macros use crate_interface under the hood, which leverages Rust’s link-time symbol resolution to connect API definitions with their implementations. This allows for a cleaner API without explicit generic parameters.

Attribute Macros§

api_def
Define an AxVisor API interface.
api_impl
Implement an AxVisor API interface.