Skip to main content

Crate dig_rpc_types

Crate dig_rpc_types 

Source
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:

§What does NOT live here

  • No I/O, no async, no server logic. No axum, no tokio, no transport. The dig-rpc server 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 String on the wire; length/charset validation is the consumer’s boundary responsibility.

§Stability

  1. ErrorCode and Method are #[non_exhaustive]; adding a code / method is additive (match with _ => …).
  2. ErrorCode numeric values and machine codes never change once assigned.
  3. Method wire names are stable.
  4. 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.