#[derive(HandleEnum)]
{
// Attributes available to this derive:
#[handle]
}
Expand description
Derive macro for type-safe handle creation and parsing.
Generates:
to_handle(&self) -> Handle- converts enum variant to Handleimpl TryFrom<&Handle>- parses Handle back to enum variantimpl From<EnumName> for Handle- convenience conversion
§Attributes
Enum-level (required):
plugin_id = "CONSTANT_NAME"- Name of the constant holding the plugin UUIDversion = "1.0.0"- Semantic version for handlescrate_path = "..."(optional, default: “plexus_core”) - Path to plexus_core crate
Variant-level:
method = "..."(required) - The handle.method valuetable = "..."(optional) - SQLite table name (for future resolution)key = "..."(optional) - Primary key column (for future resolution)
§Example
ⓘ
use hub_macro::HandleEnum;
use uuid::Uuid;
pub const MY_PLUGIN_ID: Uuid = uuid::uuid!("550e8400-e29b-41d4-a716-446655440000");
#[derive(HandleEnum)]
#[handle(plugin_id = "MY_PLUGIN_ID", version = "1.0.0")]
pub enum MyPluginHandle {
#[handle(method = "event", table = "events", key = "id")]
Event { event_id: String },
#[handle(method = "message")]
Message { message_id: String, role: String },
}
// Usage:
let handle_enum = MyPluginHandle::Event { event_id: "evt-123".into() };
let handle: Handle = handle_enum.to_handle();
// handle.method == "event"
// handle.meta == ["evt-123"]
// Parsing back:
let parsed = MyPluginHandle::try_from(&handle)?;