sigil-rpc · types
Source declarations, signatures and documentation for types.
Source: sigil/node/sigil-rpc/src/types.rs. SHA-256: b8c5f361d783d97df11a2fbf839a128280b94a537c6554f1e484577f813d5a33.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
types::JSONRPC_VERSION
The JSON-RPC protocol version we support.
pub const JSONRPC_VERSION: &str;Source line: 6.
types::RpcRequest
A JSON-RPC 2.0 request envelope.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RpcRequest {
/// Protocol version -- always `"2.0"`.
pub jsonrpc: String,
/// The RPC method name (e.g. `"sigil_getBlock"`).
pub method: String,
/// Method parameters as arbitrary JSON.
pub params: serde_json::Value,
/// Caller-provided request identifier (number or string).
pub id: serde_json::Value
}Source line: 10.
types::RpcRequest::new
Create a new request with the standard "2.0" version.
pub fn new(method: &str, params: serde_json::Value, id: serde_json::Value) -> Self;Source line: 23.
types::RpcRequest::is_valid_version
Returns true if the jsonrpc field is the supported version.
pub fn is_valid_version(&self) -> bool;Source line: 33.
types::RpcResponse
A JSON-RPC 2.0 response envelope.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RpcResponse {
/// Protocol version -- always `"2.0"`.
pub jsonrpc: String,
/// The result payload (present on success).
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<serde_json::Value>,
/// The error payload (present on failure).
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<RpcError>,
/// The request identifier echoed back.
pub id: serde_json::Value
}Source line: 40.
types::RpcResponse::success
Build a success response.
pub fn success(result: serde_json::Value, id: serde_json::Value) -> Self;Source line: 55.
types::RpcResponse::error
Build an error response.
pub fn error(error: RpcError, id: serde_json::Value) -> Self;Source line: 65.
types::RpcResponse::is_error
Returns true when the response carries an error.
pub fn is_error(&self) -> bool;Source line: 75.
types::RpcError
A JSON-RPC 2.0 error object.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RpcError {
/// Numeric error code (see JSON-RPC 2.0 spec and [`crate::error::RpcApiError`]).
pub code: i32,
/// Short human-readable error message.
pub message: String,
/// Optional structured error data.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<serde_json::Value>
}Source line: 82.
types::RpcError::new
Create a new error without additional data.
pub fn new(code: i32, message: impl Into<String>) -> Self;Source line: 94.
types::RpcError::with_data
Attach additional structured data.
pub fn with_data(mut self, data: serde_json::Value) -> Self;Source line: 103.