MCPcopy Create free account
hub / github.com/ElementsProject/lightning / deserialize

Method deserialize

cln-rpc/src/jsonrpc.rs:35–56  ·  view source on GitHub ↗
(deserializer: D)

Source from the content-addressed store, hash-verified

33 R: Deserialize<'de> + Debug,
34{
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
36 where
37 D: Deserializer<'de>,
38 {
39 #[derive(Deserialize, Debug)]
40 struct IdHelper {
41 id: Option<serde_json::Value>,
42 }
43
44 let v = Value::deserialize(deserializer)?;
45 let helper = IdHelper::deserialize(&v).map_err(de::Error::custom)?;
46 match helper.id {
47 Some(id) => {
48 let r = R::deserialize(v).map_err(de::Error::custom)?;
49 Ok(JsonRpc::Request(id, r))
50 }
51 None => {
52 let n = N::deserialize(v).map_err(de::Error::custom)?;
53 Ok(JsonRpc::Notification(n))
54 }
55 }
56 }
57}
58
59impl<N, R> Serialize for JsonRpc<N, R>

Callers

nothing calls this directly

Calls 2

RequestEnum · 0.70
NotificationEnum · 0.70

Tested by

no test coverage detected