Expand description
#[derive(PluginEvent)] — the guest-side derive for plugin-defined events
(PH7.8b.3). The companion proc-macro crate to lattice-plugin-sdk (the
serde/serde_derive split: a proc-macro crate cannot also export a normal
library, so the runtime trait lives in lattice-plugin-sdk, which re-exports
this derive).
The derive is WIT-agnostic (PH7.8b.3 approach A): it generates a
PluginEvent impl over the opaque MessagePack wire and touches no plugin-host
bindings. A plugin emits with its own generated host-services emit-event
using the derived NAME + encode(); the derive only supplies the type-safe
encode/decode + the name/doc constants.
Generated for #[derive(PluginEvent)] struct Foo { .. }:
NAME— from#[event(name = "...")], else the type name kebab-cased.DOC— the struct’s///doc-comment (the doc-comment IS the event doc, the PI.4 “doc from doc comments” principle applied to events).encode/decode— MessagePack vialattice-plugin-sdk’s private helpers, so the consumer deps only the SDK (notrmp-serdedirectly).
The consumer must also #[derive(serde::Serialize, serde::Deserialize)] —
the encode/decode bodies require it. Generated code references
::lattice_plugin_sdk, so the consumer must depend on lattice-plugin-sdk
(which uses extern crate self as lattice_plugin_sdk; so the paths resolve in
its own tests).
Derive Macros§
- Config
Shape - Derive
ConfigShapefor a struct with named fields, or for an enum whose variants are all unit. - Plugin
Event - Derive
PluginEventfor a serde-serializable struct. See the crate docs for the generated items and the#[event(name = "...")]/ doc-comment inputs. - Plugin
Option - Derive
PluginOptionfor a newtype struct overbool/i64/String(PH7.10b) — the guest-side ergonomic layer over theconfig.register-optionwire. LikePluginEvent, it is WIT-agnostic: it generates only metadata constants + the value type; the plugin makes theregister-option/get-optionWIT calls itself using them.