Skip to main content

Crate agent_client_protocol_derive

Crate agent_client_protocol_derive 

Source
Expand description

Derive macros for Agent Client Protocol JSON-RPC traits.

This crate provides derive macros to reduce boilerplate when implementing custom JSON-RPC requests, notifications, and response types.

§Example

use agent_client_protocol::{JsonRpcRequest, JsonRpcNotification, JsonRpcResponse};

#[derive(Debug, Clone, Serialize, Deserialize, JsonRpcRequest)]
#[request(method = "_hello", response = HelloResponse)]
struct HelloRequest {
    name: String,
}

#[derive(Debug, Serialize, Deserialize, JsonRpcResponse)]
#[response(method = "_hello")]
struct HelloResponse {
    greeting: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonRpcNotification)]
#[notification(method = "_ping")]
struct PingNotification {
    timestamp: u64,
}

§Using within the agent_client_protocol crate

When using these derives within the agent_client_protocol crate itself, add crate = crate:

#[derive(JsonRpcRequest)]
#[request(method = "_foo", response = FooResponse, crate = crate)]
struct FooRequest { ... }

Derive Macros§

JsonRpcNotification
Derive macro for implementing JsonRpcNotification and JsonRpcMessage traits.
JsonRpcRequest
Derive macro for implementing JsonRpcRequest and JsonRpcMessage traits.
JsonRpcResponse
Derive macro for implementing JsonRpcResponse trait.