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

Method deserialize

plugins/src/messages.rs:123–144  ·  view source on GitHub ↗
(deserializer: D)

Source from the content-addressed store, hash-verified

121 R: Deserialize<'de> + Debug,
122{
123 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
124 where
125 D: Deserializer<'de>,
126 {
127 #[derive(Deserialize, Debug)]
128 struct IdHelper {
129 id: Option<serde_json::Value>,
130 }
131
132 let v = Value::deserialize(deserializer)?;
133 let helper = IdHelper::deserialize(&v).map_err(de::Error::custom)?;
134 match helper.id {
135 Some(id) => match R::deserialize(v.clone()) {
136 Ok(r) => Ok(JsonRpc::Request(id, r)),
137 Err(_) => Ok(JsonRpc::CustomRequest(id, v)),
138 },
139 None => match N::deserialize(v.clone()) {
140 Ok(n) => Ok(JsonRpc::Notification(n)),
141 Err(_) => Ok(JsonRpc::CustomNotification(v)),
142 },
143 }
144 }
145}
146
147#[derive(Serialize, Default, Debug)]

Callers

nothing calls this directly

Calls 2

RequestEnum · 0.70
NotificationEnum · 0.70

Tested by

no test coverage detected