@@ -31,6 +31,7 @@ use bitcoin::util::{bip158, bip32};
31
31
use bitcoin:: { Address , Amount , PrivateKey , PublicKey , Script , SignedAmount , Transaction } ;
32
32
use serde:: de:: Error as SerdeError ;
33
33
use serde:: { Deserialize , Serialize } ;
34
+ use std:: fmt;
34
35
35
36
//TODO(stevenroose) consider using a Time type
36
37
@@ -402,6 +403,7 @@ pub struct FeeRatePercentiles {
402
403
pub fr_90th : Amount ,
403
404
}
404
405
406
+ #[ derive( Clone ) ]
405
407
pub enum BlockStatsFields {
406
408
AverageFee ,
407
409
AverageFeeRate ,
@@ -435,7 +437,7 @@ pub enum BlockStatsFields {
435
437
}
436
438
437
439
impl BlockStatsFields {
438
- pub fn get_rpc_keyword ( & self ) -> & str {
440
+ fn get_rpc_keyword ( & self ) -> & str {
439
441
match * self {
440
442
BlockStatsFields :: AverageFee => "avgfee" ,
441
443
BlockStatsFields :: AverageFeeRate => "avgfeerate" ,
@@ -470,6 +472,18 @@ impl BlockStatsFields {
470
472
}
471
473
}
472
474
475
+ impl fmt:: Display for BlockStatsFields {
476
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
477
+ write ! ( f, "{}" , self . get_rpc_keyword( ) )
478
+ }
479
+ }
480
+
481
+ impl From < BlockStatsFields > for serde_json:: Value {
482
+ fn from ( bsf : BlockStatsFields ) -> Self {
483
+ Self :: from ( bsf. to_string ( ) )
484
+ }
485
+ }
486
+
473
487
#[ derive( Clone , PartialEq , Debug , Deserialize , Serialize ) ]
474
488
#[ serde( rename_all = "camelCase" ) ]
475
489
pub struct GetMiningInfoResult {
@@ -1157,7 +1171,6 @@ impl<'de> serde::Deserialize<'de> for ImportMultiRescanSince {
1157
1171
D : serde:: Deserializer < ' de > ,
1158
1172
{
1159
1173
use serde:: de;
1160
- use std:: fmt;
1161
1174
struct Visitor ;
1162
1175
impl < ' de > de:: Visitor < ' de > for Visitor {
1163
1176
type Value = ImportMultiRescanSince ;
0 commit comments