@@ -31,6 +31,7 @@ use bitcoin::util::{bip158, bip32};
3131use bitcoin:: { Address , Amount , PrivateKey , PublicKey , Script , SignedAmount , Transaction } ;
3232use serde:: de:: Error as SerdeError ;
3333use serde:: { Deserialize , Serialize } ;
34+ use std:: fmt;
3435
3536//TODO(stevenroose) consider using a Time type
3637
@@ -402,6 +403,7 @@ pub struct FeeRatePercentiles {
402403 pub fr_90th : Amount ,
403404}
404405
406+ #[ derive( Clone ) ]
405407pub enum BlockStatsFields {
406408 AverageFee ,
407409 AverageFeeRate ,
@@ -435,7 +437,7 @@ pub enum BlockStatsFields {
435437}
436438
437439impl BlockStatsFields {
438- pub fn get_rpc_keyword ( & self ) -> & str {
440+ fn get_rpc_keyword ( & self ) -> & str {
439441 match * self {
440442 BlockStatsFields :: AverageFee => "avgfee" ,
441443 BlockStatsFields :: AverageFeeRate => "avgfeerate" ,
@@ -470,6 +472,18 @@ impl BlockStatsFields {
470472 }
471473}
472474
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+
473487#[ derive( Clone , PartialEq , Debug , Deserialize , Serialize ) ]
474488#[ serde( rename_all = "camelCase" ) ]
475489pub struct GetMiningInfoResult {
@@ -1157,7 +1171,6 @@ impl<'de> serde::Deserialize<'de> for ImportMultiRescanSince {
11571171 D : serde:: Deserializer < ' de > ,
11581172 {
11591173 use serde:: de;
1160- use std:: fmt;
11611174 struct Visitor ;
11621175 impl < ' de > de:: Visitor < ' de > for Visitor {
11631176 type Value = ImportMultiRescanSince ;
0 commit comments