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
//! `AcpReply` — the raw JSON-RPC 2.0 reply shape.
//!
//! # Why the peer carries a raw reply, not a typed one
//!
//! The peer is the transport layer. It does not
//! know that the wire's `result` field for an
//! `initialize` call is a typed
//! [`InitializeResponse`](crate::domain::acp::initialize::InitializeResponse);
//! the consumer is the one that deserialises the
//! raw `serde_json::Value` into the concrete type
//! the method returns. This is the same shape the
//! protocol-neutral core's
//! [`Envelope`](crate::domain::jsonrpc::envelope::Envelope)
//! has: the wire is bytes, the consumer is the
//! decoder.
//!
//! The peer's job is to *return* the value the
//! agent sent. The consumer decodes.
use Deserialize;
/// A JSON-RPC 2.0 reply: the agent's answer to a
/// request.
///
/// The wire form has either a `result` (success)
/// or an `error` (failure), never both, never
/// neither. The typed form is the same: a
/// `Result<AcpReply, AcpPeerError>` from the
/// peer's `send_request` already encodes the
/// success/failure split. The peer's
/// [`JsonRpc`](super::error::AcpPeerError::JsonRpc)
/// variant is the failure case, so the
/// `AcpReply` value the consumer receives is
/// always the success case.