@@ -14,15 +14,15 @@ use crate::lsps1::msgs::{
14
14
use crate :: lsps2:: msgs:: {
15
15
LSPS2Message , LSPS2Request , LSPS2Response , LSPS2_BUY_METHOD_NAME , LSPS2_GET_INFO_METHOD_NAME ,
16
16
} ;
17
- use crate :: prelude:: { HashMap , String , ToString } ;
17
+ use crate :: prelude:: { HashMap , String } ;
18
18
19
19
use lightning:: ln:: msgs:: LightningError ;
20
20
use lightning:: ln:: wire;
21
21
use lightning:: util:: ser:: WithoutLength ;
22
22
23
23
use bitcoin:: secp256k1:: PublicKey ;
24
24
25
- use core:: fmt:: { self , Display } ;
25
+ use core:: fmt;
26
26
use core:: str:: FromStr ;
27
27
28
28
use serde:: de:: { self , MapAccess , Visitor } ;
@@ -53,6 +53,19 @@ pub(crate) enum LSPSMethod {
53
53
LSPS2Buy ,
54
54
}
55
55
56
+ impl LSPSMethod {
57
+ fn as_static_str ( & self ) -> & ' static str {
58
+ match self {
59
+ Self :: LSPS0ListProtocols => LSPS0_LISTPROTOCOLS_METHOD_NAME ,
60
+ Self :: LSPS1GetInfo => LSPS1_GET_INFO_METHOD_NAME ,
61
+ Self :: LSPS1CreateOrder => LSPS1_CREATE_ORDER_METHOD_NAME ,
62
+ Self :: LSPS1GetOrder => LSPS1_GET_ORDER_METHOD_NAME ,
63
+ Self :: LSPS2GetInfo => LSPS2_GET_INFO_METHOD_NAME ,
64
+ Self :: LSPS2Buy => LSPS2_BUY_METHOD_NAME ,
65
+ }
66
+ }
67
+ }
68
+
56
69
impl FromStr for LSPSMethod {
57
70
type Err = & ' static str ;
58
71
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
@@ -68,20 +81,6 @@ impl FromStr for LSPSMethod {
68
81
}
69
82
}
70
83
71
- impl Display for LSPSMethod {
72
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
73
- let s = match self {
74
- Self :: LSPS0ListProtocols => LSPS0_LISTPROTOCOLS_METHOD_NAME ,
75
- Self :: LSPS1GetInfo => LSPS1_GET_INFO_METHOD_NAME ,
76
- Self :: LSPS1CreateOrder => LSPS1_CREATE_ORDER_METHOD_NAME ,
77
- Self :: LSPS1GetOrder => LSPS1_GET_ORDER_METHOD_NAME ,
78
- Self :: LSPS2GetInfo => LSPS2_GET_INFO_METHOD_NAME ,
79
- Self :: LSPS2Buy => LSPS2_BUY_METHOD_NAME ,
80
- } ;
81
- write ! ( f, "{}" , s)
82
- }
83
- }
84
-
85
84
impl From < & LSPS0Request > for LSPSMethod {
86
85
fn from ( value : & LSPS0Request ) -> Self {
87
86
match value {
@@ -124,7 +123,7 @@ impl Serialize for LSPSMethod {
124
123
where
125
124
S : serde:: Serializer ,
126
125
{
127
- serializer. serialize_str ( & self . to_string ( ) )
126
+ serializer. serialize_str ( & self . as_static_str ( ) )
128
127
}
129
128
}
130
129
@@ -407,7 +406,7 @@ impl<'de, 'a> Visitor<'de> for LSPSMessageVisitor<'a> {
407
406
if let Some ( method) = method {
408
407
return Err ( de:: Error :: custom ( format ! (
409
408
"Received unknown notification: {}" ,
410
- method
409
+ method. as_static_str ( )
411
410
) ) ) ;
412
411
} else {
413
412
if let Some ( error) = error {
0 commit comments