use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use async_trait::async_trait;
use crate::error::RpcResult;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Command {
pub command: String,
pub args: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommandResponse {
pub success: bool,
pub result: Option<serde_json::Value>,
pub error: Option<String>,
}
#[async_trait]
pub trait CommandHandler: Send + Sync {
async fn handle(&self, command: &str, args: Vec<serde_json::Value>) -> RpcResult<serde_json::Value>;
}
pub type CommandHandlers = HashMap<String, Box<dyn CommandHandler>>;
#[derive(Debug, Clone)]
pub struct RpcMessage {
pub content: Vec<u8>,
pub correlation_id: String,
pub reply_queue: Option<String>,
pub delivery_tag: u64,
}