#[program]
Expand description
Generates code for turning a Rust impl block into a Sails program based on a set of public methods of the block. See documentation for details.
The macro can be customized with the following arguments:
crate
- specifies path to thesails-rs
crate allowing the latter to be imported with a different name, for example, when thesails-rs
create is re-exprted from another crate.handle_signal
- specifies a path to a function that will be called after standard signal handling provided by thegstd
crate.payable
- specifies that the program can accept transfers of value.
The macro also accepts a handle_reply
attribute that can be used to specify a function
that will handle replies. This function should be defined within the program and accepts &self
.
The function will be called automatically when a reply is received.
ยงExamples
mod my_program {
use sails_rs::program;
pub struct MyProgram;
#[program(payable)]
impl MyProgram {
pub fn default() -> Self {
Self
}
pub fn from_seed(_seed: u32) -> Self {
Self
}
#[handle_reply]
fn inspect_reply(&self) {
// Handle reply here
}
}
}