Expand description
§starlang-macros
Ergonomic macros for Starlang.
This crate provides procedural macros that make working with Starlang more convenient and Elixir-like.
§Available Macros
§#[main]
Entry point macro that sets up both tokio and the Starlang runtime:
ⓘ
#[starlang::main]
async fn main(handle: RuntimeHandle) -> Result<(), Box<dyn std::error::Error>> {
// Start your processes here
let pid = handle.spawn(|ctx| async move {
// Process logic
});
Ok(())
}§receive!
Pattern matching on received messages with optional timeout:
ⓘ
receive! { ctx,
MyMessage::Ping => {
println!("Got ping!");
},
MyMessage::Data(x) => {
println!("Got data: {}", x);
},
after Duration::from_secs(5) => {
println!("Timeout!");
}
}§#[derive(GenServerImpl)]
Derive macro for implementing GenServer boilerplate (future feature).
Macros§
- self_
pid - Returns the current process’s PID from task-local storage.
Attribute Macros§
- main
- Entry point macro that sets up both tokio and the Starlang runtime.
- starlang_
process - Attribute macro for marking async functions as Starlang processes.
Derive Macros§
- GenServer
Impl - Derive macro for GenServer implementation helpers.