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

Method serialize

plugins/lsps-plugin/src/proto/jsonrpc.rs:176–196  ·  view source on GitHub ↗
(&self, serializer: S)

Source from the content-addressed store, hash-verified

174// Custom Serialize to match JSON-RPC 2.0 wire format
175impl<R: Serialize> Serialize for JsonRpcResponse<R> {
176 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
177 where
178 S: serde::Serializer,
179 {
180 use serde::ser::SerializeStruct;
181
182 let mut state = serializer.serialize_struct("JsonRpcResponse", 3)?;
183 state.serialize_field("jsonrpc", "2.0")?;
184 state.serialize_field("id", &self.id)?;
185
186 match &self.body {
187 JsonRpcResponseBody::Success { result } => {
188 state.serialize_field("result", result)?;
189 }
190 JsonRpcResponseBody::Error { error } => {
191 state.serialize_field("error", error)?;
192 }
193 }
194
195 state.end()
196 }
197}
198
199// Custom Deserialize from JSON-RPC 2.0 wire format

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected