Skip to content

Native Macros (flame-macro)

flame-macro provides procedural macro attributes for developing native Rust plugins in Flame. Use these macros to control how your Rust code is exported into .fmi (Flame Meta Interface) configurations—such as skipping exports, renaming identifiers, or managing runtime process waits (daemons).


In your native Rust plugin’s Cargo.toml:

[dependencies]
flame-macro = "0.1.0"

Marks an asynchronous function as a long-running daemon (such as an Axum server or WebSocket listener). This informs the Flame runtime to engage a persistent daemon lock until user interrupt (Ctrl+C):

use flame_macro::flame;
impl FlameServer {
#[flame(daemon)]
pub async fn listen(self, port: u16) -> std::io::Result<()> {
let addr = SocketAddr::from(([127, 0, 0, 1], port));
let listener = tokio::net::TcpListener::bind(addr).await?;
axum::serve(listener, self.router).await.map_err(std::io::Error::other)
}
}

Marks an associated method as the default constructor when instantiated from Flame code:

use flame_macro::flame;
pub struct DatabasePool { ... }
impl DatabasePool {
#[flame(constructor)]
pub fn connect(url: &str) -> Self {
...
}
}

Hides internal Rust functions, helper methods, or fields from being exported to .fmi metadata and VS Code autocomplete:

use flame_macro::flame;
impl MyPlugin {
#[flame(skip)]
pub fn internal_helper(&self) {
// Not visible to Flame scripts
}
}

Customizes the identifier exposed to Flame scripts:

use flame_macro::flame;
impl MyPlugin {
#[flame(rename = "fetch_data")]
pub fn rust_internal_fetch_routine(&self) -> String {
"data".toString()
}
}