dig-rpc-types 0.2.1

Canonical DIG-node JSON-RPC interface: request/response types, the method enum + tier classification, the error-code taxonomy, and an OpenRPC 1.2.6 document generator. The single source of truth both DIG node implementations depend on. Pure types — no I/O, no async, no server logic.
Documentation

dig-rpc-types

The canonical DIG-node JSON-RPC interface — the single source of truth both DIG node implementations (the digstore dig-node crate and the standalone dig-node binary) depend on instead of hand-rolling json!({…}) shapes and ad-hoc error codes.

Pure types: no I/O, no async, no server logic, no crypto. The dig-rpc server crate and the node implementations build on these types.

What's here

Module Contents
envelope JSON-RPC 2.0 request/response, RequestId, Version
error the canonical ErrorCode taxonomy, the RpcError envelope ({code, message, data:{code, origin}}), and the one constructor helper
method the Method enum — stable wire names, per-method Tier, the mTLS peer allowlist
tier the three access tiers (PublicRead / Peer / Control)
types every method's params + results, field-for-field with the canonical node
frames the shape-dispatched DHT + PEX peer wires
openrpc the OpenRPC 1.2.6 document generator (the single discovery source)

The full contract is in SPEC.md.

Error taxonomy at a glance

Standard JSON-RPC codes plus the DIG protocol codes. The onion codes -32020/-32021/-32022 are the published normative contract and keep their numbers; the control-plane codes are -32030/-32031/-32032.

use dig_rpc_types::{RpcError, ErrorCode, ErrorOrigin};

let e = RpcError::of(ErrorCode::ResourceUnavailable, "not at this root");
assert_eq!(e.code, ErrorCode::ResourceUnavailable);       // -32004
assert_eq!(e.data.code, "RESOURCE_UNAVAILABLE");          // stable branch key
assert_eq!(e.data.origin, ErrorOrigin::Node);

Method catalogue + discovery

use dig_rpc_types::{Method, Tier, openrpc_document};

assert_eq!(Method::GetContent.name(), "dig.getContent");
assert_eq!(Method::GetContent.tier(), Tier::PublicRead);
assert!(Method::GetContent.is_peer_reachable());
assert!(!Method::CacheClear.is_peer_reachable());          // control tier

let doc = openrpc_document(env!("CARGO_PKG_VERSION"));      // OpenRPC 1.2.6

Features

Flag Default Effect
schema-export off derive schemars::JsonSchema on every wire type (Go/TS codegen)

Testing

cargo test --all-features        # unit + conformance vectors
cargo llvm-cov --all-features    # coverage (CI-gated ≥80%)

Licensed under Apache-2.0 OR MIT.