Skip to main content

Crate coralstack_cmd_ipc_macros

Crate coralstack_cmd_ipc_macros 

Source
Expand description

Procedural macros for [coralstack-cmd-ipc].

This crate provides four attribute macros that keep command and event definitions concise and colocated with their handlers:

  • command — mark one async fn/method as a command.
  • command_service — mark an impl block; every method inside tagged with #[command("id")] becomes a registered command and the block gains a generated register(self, &registry) helper that installs every command in one call.
  • event — mark a payload struct as a typed event; emits the impl Event and auto-derives Serialize / Deserialize / JsonSchema.
  • payload — mark any struct (typically command requests and responses) to auto-derive Serialize / Deserialize / JsonSchema without requiring the user crate to depend on serde / schemars directly.

All four resolve their derives against the serde / schemars re-exports published by coralstack-cmd-ipc, so user crates depend on coralstack-cmd-ipc alone.

See the coralstack-cmd-ipc crate docs for usage examples and end-to-end integration tests.

Attribute Macros§

command
Attach to an async fn (free-standing or inside a #[command_service] impl block) to register it as a typed command.
command_service
Attach to an impl block whose methods are tagged with #[command].
event
Attach to a payload struct to register it as a typed event.
payload
Attach to a plain data struct to auto-derive Serialize, Deserialize, and JsonSchema. Use for command request / response types (and any other struct you want those traits on) so user crates only need to depend on coralstack-cmd-ipc.