Expand description
§plexus-macros
Procedural macros for Plexus RPC activations. Your Rust function signature IS the schema — the macros extract method names, parameter types, return types, doc comments, deprecation metadata, child routing, and typed request extraction from the source.
See the crate-level README
for a comprehensive example covering every option, a deep-dive on
request forwarding (PlexusRequest + request = ...), and a
per-macro reference.
§Quick example
ⓘ
use futures::Stream;
use async_stream::stream;
use plexus_macros::PlexusRequest;
#[derive(PlexusRequest)]
pub struct BashRequest {
#[from_cookie("access_token")]
auth_token: String,
}
pub struct Bash;
#[plexus_macros::activation(
namespace = "bash",
version = "1.0.0",
description = "Execute bash commands and stream output",
request = BashRequest,
)]
impl Bash {
/// Execute a bash command and stream output.
#[plexus_macros::method(streaming)]
async fn execute(
&self,
command: String,
#[activation_param] auth_token: String,
) -> impl Stream<Item = String> + Send + 'static {
let _ = (command, auth_token);
stream! { yield "ok".into(); }
}
}§Macros at a glance
| Macro | Purpose |
|---|---|
#[plexus_macros::activation] | Turn an impl block into a Plexus RPC activation. |
#[plexus_macros::method] | Mark a method as an RPC endpoint. |
#[plexus_macros::child] | Register a child activation for ChildRouter dispatch. |
#[plexus_macros::removed_in] | Companion to #[deprecated] carrying the removal version. |
#[derive(PlexusRequest)] | Typed extraction from RawRequestContext. |
#[derive(HandleEnum)] | Type-safe handle enums for an activation. |
Deprecated surfaces kept through 0.5.x (removed in 0.6): #[hub_methods],
#[hub_method], #[derive(StreamEvent)], the hub and children = [...]
flags on #[activation]. See the migration section of the README.
Attribute Macros§
- activation
- Attribute macro for impl blocks defining a Plexus activation.
- child
- Attribute macro for individual child methods within a
#[plexus_macros::activation]impl block. - hub_
method Deprecated - Deprecated: use
plexus::methodinstead. - hub_
methods Deprecated - Deprecated: use
plexus::activationinstead. - method
- Attribute macro for individual methods within a
#[plexus::activation]impl block. - removed_
in - Companion attribute to Rust’s built-in
#[deprecated]for carrying aremoved_in = "VERSION"hint that rustc doesn’t recognize.
Derive Macros§
- Handle
Enum - Derive macro for type-safe handle creation and parsing.
- Plexus
Request - Derive macro for typed HTTP/WebSocket request extraction.
- Stream
Event Deprecated - DEPRECATED: This derive macro is no longer needed.