Expand description
§dig-rpc-types
The canonical DIG-node JSON-RPC interface. This crate is 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:
- the JSON-RPC 2.0
envelope—JsonRpcRequest,JsonRpcResponse,RequestId,Version; - the canonical error taxonomy —
ErrorCode, theRpcErrorenvelope ({code, message, data:{code, origin}}), and the one constructor helper both nodes call; - the method catalogue —
Methodwith stable wire names, the per-methodTier, and the mTLS peer allowlist; - the wire types for every method’s params + results, field-for-field
with the canonical node (network-profile-only fields
Option+ doc-flagged); - the shape-dispatched peer frame families — the DHT and PEX wires;
- the OpenRPC 1.2.6 generator — the single discovery document, generated from the tables above so discovery can never drift.
§What does NOT live here
- No I/O, no async, no server logic. No axum, no tokio, no transport. The
dig-rpcserver crate and the node implementations build on these types. This crate MUST NOT depend on any server or service crate. - No crypto. Hex identifiers are
Stringon the wire; length/charset validation is the consumer’s boundary responsibility.
§Stability
ErrorCodeandMethodare#[non_exhaustive]; adding a code / method is additive (match with_ => …).ErrorCodenumeric values and machine codes never change once assigned.- Method wire names are stable.
- The tier map and the peer allowlist mirror the canonical node exactly.
§Example — build and inspect an error envelope
use dig_rpc_types::{RpcError, ErrorCode, ErrorOrigin};
let e = RpcError::of(ErrorCode::ResourceUnavailable, "not at this root");
assert_eq!(e.code, ErrorCode::ResourceUnavailable);
assert_eq!(e.data.code, "RESOURCE_UNAVAILABLE");
assert_eq!(e.data.origin, ErrorOrigin::Node);Re-exports§
pub use envelope::JsonRpcRequest;pub use envelope::JsonRpcResponse;pub use envelope::JsonRpcResponseBody;pub use envelope::RequestId;pub use envelope::Version;pub use error::ErrorCode;pub use error::ErrorData;pub use error::ErrorOrigin;pub use error::RpcError;pub use method::Method;pub use openrpc::openrpc_document;pub use openrpc::OPENRPC_VERSION;pub use tier::Tier;
Modules§
- envelope
- JSON-RPC 2.0 envelope types.
- error
- The canonical DIG-node RPC error taxonomy.
- frames
- Shape-dispatched peer frame families: the DHT wire and the PEX wire.
- method
- The canonical DIG-node RPC method catalogue.
- openrpc
- OpenRPC 1.2.6 document generation.
- tier
- RPC access tiers and the peer-surface allowlist.
- types
- Request/response wire types for every DIG-node RPC method.
Constants§
- INTERFACE_
VERSION - The interface (wire-schema) version this crate defines. Bumped only on a wire-breaking change; additive changes leave it untouched.