Skip to main content

PluginOption

Derive Macro PluginOption 

Source
#[derive(PluginOption)]
{
    // Attributes available to this derive:
    #[option]
}
Expand description

Derive PluginOption for a newtype struct over bool / i64 / String (PH7.10b) — the guest-side ergonomic layer over the config.register-option wire. Like PluginEvent, it is WIT-agnostic: it generates only metadata constants + the value type; the plugin makes the register-option / get-option WIT calls itself using them.

#[derive(PluginOption)] #[option(default = "8")] struct TabWidth(i64); generates:

  • NAME — from #[option(name = "...")], else the type name kebab-cased.
  • DOC — the struct’s /// doc-comment.
  • DEFAULT — the required #[option(default = "...")] string.
  • KIND — the OptionKind inferred from the field type (bool→Boolean, i64→Integer, String→String).
  • type Value — the field type (parse a get-option result via lattice_plugin_sdk::parse_option).