sv::msg_attr
attribute
Use sv::msg_attr
to forward an external attribute to the generated message.
Macros
List of macros supporting the sv::msg_attr
attribute:
Usage
Use the sv::msg_attr
above any of the methods marked with #[sv::msg(..)]
attribute.
pub struct Contract;
#[contract]
#[sv::msg_attr(instantiate, derive(MyDeriveMacro))]
#[sv::msg_attr(instantiate, MyAttributeMacro(param))]
#[sv::msg_attr(instantiate, AttributeForMacro(param1, param2))]
impl Contract {
pub fn new() -> Self {
Self
}
#[sv::msg(instantiate)]
fn instantiate(&self, ctx: InstantiateCtx) -> StdResult<Response> {
Ok(Response::new())
}
}
The contract
and interface
macros will decorate the message with
the attributes/macros provided in sv::msg_attr
.
#[derive(
sylvia::serde::Serialize,
sylvia::serde::Deserialize,
Clone,
Debug,
PartialEq,
sylvia::schemars::JsonSchema,
MyDeriveMacro,
)]
#[MyAttributeMacro(param)]
#[AttributeForMacro(param1, param2)]
#[serde(rename_all = "snake_case")]
pub struct InstantiateMsg {}