The near sdk's #[near_bindgen] allows generating code for "impl" blocks, whether they are direct impls on structures, or impls of traits into structures.
The objective of the generated code is to:
- Expose a function from the wasm binary (if they are public).
- Parsing of arguments and some helper/common interface behavior, such as denying payments when invoking some particular function.
- Calling the actual method implementation, passing the arguments and the state.
- Managing state storage from the modified data in RAM.
The #[contract] proc-macro should behave similarly, by mostly doing points 2-4.
In overall, #[contract] should be applicable for:
The near sdk's
#[near_bindgen]allows generating code for "impl" blocks, whether they are direct impls on structures, or impls of traits into structures.The objective of the generated code is to:
The
#[contract]proc-macro should behave similarly, by mostly doing points 2-4.Args) and also a structure to represent a type that can be specialized into a method call (Serve), both of those assuming that generics are present.See more in Public items #14.
See more in Generate macro for extern "C" function generation #12.
In overall,
#[contract]should be applicable for:#[contract]trait definition#[contract]trait definition