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

Interface JsonRpcRequest

plugins/lsps-plugin/src/proto/jsonrpc.rs:18–38  ·  view source on GitHub ↗

Trait for types that can be converted into JSON-RPC request objects. Implementing this trait allows a struct to be used as a typed JSON-RPC request, with an associated method name and automatic conversion to the request format.

Source from the content-addressed store, hash-verified

16/// request, with an associated method name and automatic conversion to the
17/// request format.
18pub trait JsonRpcRequest: Serialize {
19 const METHOD: &'static str;
20 fn into_request(self) -> RequestObject<Self>
21 where
22 Self: Sized,
23 {
24 Self::into_request_with_id(self, Some(generate_random_id()))
25 }
26
27 fn into_request_with_id(self, id: Option<String>) -> RequestObject<Self>
28 where
29 Self: Sized,
30 {
31 RequestObject {
32 jsonrpc: "2.0".into(),
33 method: Self::METHOD.into(),
34 params: Some(self),
35 id,
36 }
37 }
38}
39
40/// Generates a random ID for JSON-RPC requests.
41///

Callers 5

list_protocolsMethod · 0.80
get_infoMethod · 0.80
buyMethod · 0.80

Implementers 4

lsps0.rsplugins/lsps-plugin/src/proto/lsps0.rs
lsps2.rsplugins/lsps-plugin/src/proto/lsps2.rs
test_empty_params_serializationplugins/lsps-plugin/src/proto/jsonrpc.
test_request_serialization_and_deserializationplugins/lsps-plugin/src/proto/jsonrpc.

Calls

no outgoing calls

Tested by

no test coverage detected