pub trait MacroPlugin: Debug + Sync + Send {
    // Required methods
    fn generate_code(
        &self,
        db: &dyn SyntaxGroup,
        item_ast: Item
    ) -> PluginResult;
    fn declared_attributes(&self) -> Vec<String>;
}
Expand description

A trait for a macro plugin: external plugin that generates additional code for items.

Required Methods§

source

fn generate_code(&self, db: &dyn SyntaxGroup, item_ast: Item) -> PluginResult

Generates code for an item. If no code should be generated returns None. Otherwise, returns (virtual_module_name, module_content), and a virtual submodule with that name and content should be created.

source

fn declared_attributes(&self) -> Vec<String>

Attributes this plugin uses. Attributes the plugin uses without declaring here are likely to cause a compilation error for unknown attribute. Note: They may not cause a diagnostic if some other plugin declares such attribute, but plugin writers should not rely on that.

Implementors§