Skip to main content

contract

Attribute Macro contract 

Source
#[contract]
Expand description

The main contract proc macro.

Applied to a module containing a contract struct and impl block. Extracts metadata and generates schema + extern wrappers.

ยงErrors

This macro will produce compile errors if:

  • The module has no content (just a declaration like mod foo;)
  • The module contains glob imports (use foo::*)
  • The module contains relative imports (use self::, use super::, use crate::)
  • The module contains multiple pub struct declarations
  • The module contains no pub struct
  • The module contains no impl block for the contract struct
  • A public method has no self receiver (associated functions)
  • A public method has generic type or const parameters
  • A public method is async
  • A public method consumes self instead of borrowing it
  • A public method uses impl Trait in parameters or return type