Native Macros (flame-macro)
flame-macro provides procedural macro attributes for developing native Rust plugins in Flame.
Installation
Section titled “Installation”In your native Rust plugin’s Cargo.toml:
[dependencies]flame-macro = "0.1.0"Macro Attributes
Section titled “Macro Attributes”#[flame(daemon)] / #[flame(runtime)]
Section titled “#[flame(daemon)] / #[flame(runtime)]”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) }}#[flame(constructor)]
Section titled “#[flame(constructor)]”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 { ... }}#[flame(skip)]
Section titled “#[flame(skip)]”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 }}#[flame(rename = "name")]
Section titled “#[flame(rename = "name")]”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() }}