pub enum RpcResponse {
Success {
jsonrpc: JsonRpcVersion,
id: RpcId,
result: Value,
},
Failure {
jsonrpc: JsonRpcVersion,
id: RpcId,
error: Value,
},
}Expand description
A JSON-RPC 2.0 response (worker -> host): result XOR error, never both, never neither
(JSON-RPC 2.0 §5). Modeled as an untagged enum of two complete structs so the illegal
states are unrepresentable. Deliberately NOT #[serde(flatten)] over an untagged inner enum
— that serde combination double-buffers (flatten → map, untagged → Content) and is a known
deserialize failure mode (fails outright or degrades integers to floats).
The XOR is enforced at the deserialize boundary by a hand-written Deserialize (below), not
merely asserted by the type shape: a plain untagged derive would match Success first and
silently DROP a present error when both keys appear, letting a failed worker call read back
as a bogus success. Serialize stays derived (untagged → each variant emits just its fields).
Variants§
Trait Implementations§
Source§impl Clone for RpcResponse
impl Clone for RpcResponse
Source§fn clone(&self) -> RpcResponse
fn clone(&self) -> RpcResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more