1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! # 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](error) — [`ErrorCode`], the
//! [`RpcError`] envelope (`{code, message, data:{code, origin}}`), and the one
//! constructor helper both nodes call;
//! - the [method catalogue](method) — [`Method`] with stable wire names, the
//! per-method [`Tier`], and the mTLS peer allowlist;
//! - the [wire types](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](frames) — the DHT and PEX wires;
//! - the [OpenRPC 1.2.6 generator](openrpc) — 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-rpc`](https://crates.io/crates/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-export the most-used items at the crate root.
pub use ;
pub use ;
pub use Method;
pub use ;
pub use Tier;
/// The interface (wire-schema) version this crate defines. Bumped only on a
/// wire-breaking change; additive changes leave it untouched.
pub const INTERFACE_VERSION: &str = "1";