Expand description
Proc macros for the Hush workflow engine.
Provides:
#[hush_op]— auto-register Rust ops viainventory#[hush_model]— shorthand for#[derive(Serialize, Deserialize, Debug, Clone)]
§Usage
ⓘ
use hush_serve::{hush_op, hush_model};
#[hush_model]
struct Conversation { vads: Vec<Vad> }
// Legacy style (untyped):
#[hush_op]
fn double(inputs: &Value) -> Value {
let x = inputs["x"].as_i64().unwrap();
serde_json::json!({"result": x * 2})
}
// Typed style (auto-generates serde wrapper):
#[hush_op]
fn classify(conversation: Conversation, threshold: f64) -> ClassifyResult {
// Pure business logic — no JSON parsing
}
#[hush_op(generator)]
fn each_item(inputs: &Value) -> Value {
let items = inputs["items"].as_array().unwrap();
Value::Array(items.iter().map(|i| serde_json::json!({"value": i})).collect())
}Attribute Macros§
- hush_
model - Shorthand for
#[derive(Serialize, Deserialize, Debug, Clone)]. - hush_op
- Auto-register a function as a Hush op.
- hush_
resource - Auto-register a function as a resource factory.