@@ -46,9 +46,9 @@ use crate::{
4646 types:: { BlsPublicKey , Chain , Jwt , JwtClaims , ModuleId } ,
4747} ;
4848
49- const APPLICATION_JSON : & str = "application/json" ;
50- const APPLICATION_OCTET_STREAM : & str = "application/octet-stream" ;
51- const WILDCARD : & str = "*/*" ;
49+ pub const APPLICATION_JSON : & str = "application/json" ;
50+ pub const APPLICATION_OCTET_STREAM : & str = "application/octet-stream" ;
51+ pub const WILDCARD : & str = "*/*" ;
5252
5353const MILLIS_PER_SECOND : u64 = 1_000 ;
5454pub const CONSENSUS_VERSION_HEADER : & str = "Eth-Consensus-Version" ;
@@ -498,21 +498,28 @@ pub enum EncodingType {
498498 Ssz ,
499499}
500500
501- impl std:: fmt:: Display for EncodingType {
502- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
501+ impl EncodingType {
502+ /// Get the content type string for the encoding type
503+ pub fn content_type ( & self ) -> & str {
503504 match self {
504- EncodingType :: Json => write ! ( f , "application/json" ) ,
505- EncodingType :: Ssz => write ! ( f , "application/octet-stream" ) ,
505+ EncodingType :: Json => APPLICATION_JSON ,
506+ EncodingType :: Ssz => APPLICATION_OCTET_STREAM ,
506507 }
507508 }
508509}
509510
511+ impl std:: fmt:: Display for EncodingType {
512+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
513+ write ! ( f, "{}" , self . content_type( ) )
514+ }
515+ }
516+
510517impl FromStr for EncodingType {
511518 type Err = String ;
512519 fn from_str ( value : & str ) -> Result < Self , Self :: Err > {
513520 match value. to_ascii_lowercase ( ) . as_str ( ) {
514- "application/json" | "" => Ok ( EncodingType :: Json ) ,
515- "application/octet-stream" => Ok ( EncodingType :: Ssz ) ,
521+ APPLICATION_JSON | "" => Ok ( EncodingType :: Json ) ,
522+ APPLICATION_OCTET_STREAM => Ok ( EncodingType :: Ssz ) ,
516523 _ => Err ( format ! ( "unsupported encoding type: {value}" ) ) ,
517524 }
518525 }
0 commit comments