11//! Message, request, and other primitive types used to implement LSPS0. 
22
3- use  crate :: lsps0:: ser:: { LSPSMessage ,  RequestId ,   ResponseError } ; 
3+ use  crate :: lsps0:: ser:: { LSPSMessage ,  LSPSRequestId ,   LSPSResponseError } ; 
44use  crate :: prelude:: Vec ; 
55
66use  serde:: { Deserialize ,  Serialize } ; 
@@ -15,15 +15,15 @@ pub(crate) const LSPS0_LISTPROTOCOLS_METHOD_NAME: &str = "lsps0.list_protocols";
1515/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) 
1616/// for more information. 
1717#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ,  Deserialize ,  Serialize ,  Default ) ]  
18- pub  struct  ListProtocolsRequest  { } 
18+ pub  struct  LSPS0ListProtocolsRequest  { } 
1919
2020/// A response to a `list_protocols` request. 
2121/// 
2222/// Please refer to the [bLIP-50 / LSPS0 
2323/// specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query) 
2424/// for more information. 
2525#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ,  Deserialize ,  Serialize ) ]  
26- pub  struct  ListProtocolsResponse  { 
26+ pub  struct  LSPS0ListProtocolsResponse  { 
2727	/// A list of supported protocols. 
2828 	pub  protocols :  Vec < u16 > , 
2929} 
@@ -36,12 +36,12 @@ pub struct ListProtocolsResponse {
3636#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
3737pub  enum  LSPS0Request  { 
3838	/// A request calling `list_protocols`. 
39-  	ListProtocols ( ListProtocolsRequest ) , 
39+  	ListProtocols ( LSPS0ListProtocolsRequest ) , 
4040} 
4141
4242impl  LSPS0Request  { 
4343	/// Returns the method name associated with the given request variant. 
44-  	pub  fn  method ( & self )  -> & str  { 
44+  	pub  fn  method ( & self )  -> & ' static   str  { 
4545		match  self  { 
4646			LSPS0Request :: ListProtocols ( _)  => LSPS0_LISTPROTOCOLS_METHOD_NAME , 
4747		} 
@@ -56,9 +56,9 @@ impl LSPS0Request {
5656#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
5757pub  enum  LSPS0Response  { 
5858	/// A response to a `list_protocols` request. 
59-  	ListProtocols ( ListProtocolsResponse ) , 
59+  	ListProtocols ( LSPS0ListProtocolsResponse ) , 
6060	/// An error response to a `list_protocols` request. 
61-  	ListProtocolsError ( ResponseError ) , 
61+  	ListProtocolsError ( LSPSResponseError ) , 
6262} 
6363
6464/// An bLIP-50 / LSPS0 protocol message. 
@@ -69,9 +69,9 @@ pub enum LSPS0Response {
6969#[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
7070pub  enum  LSPS0Message  { 
7171	/// A request variant. 
72-  	Request ( RequestId ,  LSPS0Request ) , 
72+  	Request ( LSPSRequestId ,  LSPS0Request ) , 
7373	/// A response variant. 
74-  	Response ( RequestId ,  LSPS0Response ) , 
74+  	Response ( LSPSRequestId ,  LSPS0Response ) , 
7575} 
7676
7777impl  TryFrom < LSPSMessage >  for  LSPS0Message  { 
@@ -117,17 +117,17 @@ mod tests {
117117		assert_eq ! ( 
118118			msg, 
119119			LSPSMessage :: LSPS0 ( LSPS0Message :: Request ( 
120- 				RequestId ( "request:id:xyz123" . to_string( ) ) , 
121- 				LSPS0Request :: ListProtocols ( ListProtocolsRequest  { } ) 
120+ 				LSPSRequestId ( "request:id:xyz123" . to_string( ) ) , 
121+ 				LSPS0Request :: ListProtocols ( LSPS0ListProtocolsRequest  { } ) 
122122			) ) 
123123		) ; 
124124	} 
125125
126126	#[ test]  
127127	fn  serializes_request ( )  { 
128128		let  request = LSPSMessage :: LSPS0 ( LSPS0Message :: Request ( 
129- 			RequestId ( "request:id:xyz123" . to_string ( ) ) , 
130- 			LSPS0Request :: ListProtocols ( ListProtocolsRequest  { } ) , 
129+ 			LSPSRequestId ( "request:id:xyz123" . to_string ( ) ) , 
130+ 			LSPS0Request :: ListProtocols ( LSPS0ListProtocolsRequest  { } ) , 
131131		) ) ; 
132132		let  json = serde_json:: to_string ( & request) . unwrap ( ) ; 
133133		assert_eq ! ( 
@@ -147,16 +147,18 @@ mod tests {
147147	    }"# ; 
148148		let  mut  request_id_to_method_map = new_hash_map ( ) ; 
149149		request_id_to_method_map
150- 			. insert ( RequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
150+ 			. insert ( LSPSRequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
151151
152152		let  response =
153153			LSPSMessage :: from_str_with_id_map ( json,  & mut  request_id_to_method_map) . unwrap ( ) ; 
154154
155155		assert_eq ! ( 
156156			response, 
157157			LSPSMessage :: LSPS0 ( LSPS0Message :: Response ( 
158- 				RequestId ( "request:id:xyz123" . to_string( ) ) , 
159- 				LSPS0Response :: ListProtocols ( ListProtocolsResponse  {  protocols:  vec![ 1 ,  2 ,  3 ]  } ) 
158+ 				LSPSRequestId ( "request:id:xyz123" . to_string( ) ) , 
159+ 				LSPS0Response :: ListProtocols ( LSPS0ListProtocolsResponse  { 
160+ 					protocols:  vec![ 1 ,  2 ,  3 ] 
161+ 				} ) 
160162			) ) 
161163		) ; 
162164	} 
@@ -173,16 +175,16 @@ mod tests {
173175	    }"# ; 
174176		let  mut  request_id_to_method_map = new_hash_map ( ) ; 
175177		request_id_to_method_map
176- 			. insert ( RequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
178+ 			. insert ( LSPSRequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
177179
178180		let  response =
179181			LSPSMessage :: from_str_with_id_map ( json,  & mut  request_id_to_method_map) . unwrap ( ) ; 
180182
181183		assert_eq ! ( 
182184			response, 
183185			LSPSMessage :: LSPS0 ( LSPS0Message :: Response ( 
184- 				RequestId ( "request:id:xyz123" . to_string( ) ) , 
185- 				LSPS0Response :: ListProtocolsError ( ResponseError  { 
186+ 				LSPSRequestId ( "request:id:xyz123" . to_string( ) ) , 
187+ 				LSPS0Response :: ListProtocolsError ( LSPSResponseError  { 
186188					code:  -32617 , 
187189					message:  "Unknown Error" . to_string( ) , 
188190					data:  None 
@@ -202,7 +204,7 @@ mod tests {
202204	    }"# ; 
203205		let  mut  request_id_to_method_map = new_hash_map ( ) ; 
204206		request_id_to_method_map
205- 			. insert ( RequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
207+ 			. insert ( LSPSRequestId ( "request:id:xyz123" . to_string ( ) ) ,  LSPSMethod :: LSPS0ListProtocols ) ; 
206208
207209		let  response = LSPSMessage :: from_str_with_id_map ( json,  & mut  request_id_to_method_map) ; 
208210		assert ! ( response. is_err( ) ) ; 
@@ -211,8 +213,8 @@ mod tests {
211213	#[ test]  
212214	fn  serializes_response ( )  { 
213215		let  response = LSPSMessage :: LSPS0 ( LSPS0Message :: Response ( 
214- 			RequestId ( "request:id:xyz123" . to_string ( ) ) , 
215- 			LSPS0Response :: ListProtocols ( ListProtocolsResponse  {  protocols :  vec ! [ 1 ,  2 ,  3 ]  } ) , 
216+ 			LSPSRequestId ( "request:id:xyz123" . to_string ( ) ) , 
217+ 			LSPS0Response :: ListProtocols ( LSPS0ListProtocolsResponse  {  protocols :  vec ! [ 1 ,  2 ,  3 ]  } ) , 
216218		) ) ; 
217219		let  json = serde_json:: to_string ( & response) . unwrap ( ) ; 
218220		assert_eq ! ( 
0 commit comments