repl-proto 1.8.0

JSON-RPC wire protocol types for the Symbi platform
Documentation
use serde::{Deserialize, Serialize};

/// Represents a JSON-RPC request.
#[derive(Debug, Serialize, Deserialize)]
pub struct Request {
    pub id: u64,
    pub method: String,
    pub params: serde_json::Value,
}

/// Represents a successful JSON-RPC response.
#[derive(Debug, Serialize, Deserialize)]
pub struct Response {
    pub id: u64,
    pub result: serde_json::Value,
}

/// Represents a JSON-RPC error object.
#[derive(Debug, Serialize, Deserialize)]
pub struct ErrorObject {
    pub code: i64,
    pub message: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<serde_json::Value>,
}

/// Represents an error JSON-RPC response.
#[derive(Debug, Serialize, Deserialize)]
pub struct ErrorResponse {
    pub id: u64,
    pub error: ErrorObject,
}

/// Parameters for the `evaluate` method.
#[derive(Debug, Serialize, Deserialize)]
pub struct EvaluateParams {
    pub code: String,
}

/// Successful result for the `evaluate` method.
#[derive(Debug, Serialize, Deserialize)]
pub struct EvaluateResult {
    pub output: String,
}

/// Represents a command entered by the user.
#[derive(Debug, Serialize, Deserialize)]
pub struct CommandLog {
    pub timestamp: String,
    pub command: String,
}

/// Represents the output generated by a command.
#[derive(Debug, Serialize, Deserialize)]
pub struct OutputLog {
    pub timestamp: String,
    pub output: String,
}