@@ -466,11 +466,11 @@ pub enum VersionedAttestation {
466466
467467impl Encode for VersionedAttestation {
468468 fn size_hint ( & self ) -> usize {
469- self . to_scale ( ) . len ( )
469+ self . to_bytes ( ) . len ( )
470470 }
471471
472472 fn encode_to < T : Output + ?Sized > ( & self , dest : & mut T ) {
473- dest. write ( & self . to_scale ( ) ) ;
473+ dest. write ( & self . to_bytes ( ) ) ;
474474 }
475475}
476476
@@ -483,7 +483,7 @@ impl Decode for VersionedAttestation {
483483 } ;
484484 let mut bytes = vec ! [ 0u8 ; remaining_len] ;
485485 input. read ( & mut bytes) ?;
486- Self :: from_scale ( & bytes) . map_err ( |err| {
486+ Self :: from_bytes ( & bytes) . map_err ( |err| {
487487 ScaleError :: from ( std:: io:: Error :: new (
488488 std:: io:: ErrorKind :: InvalidData ,
489489 err. to_string ( ) ,
@@ -494,30 +494,30 @@ impl Decode for VersionedAttestation {
494494
495495impl VersionedAttestation {
496496 /// Decode versioned attestation bytes.
497- pub fn from_scale ( scale : & [ u8 ] ) -> Result < Self > {
498- let Some ( first) = scale . first ( ) . copied ( ) else {
497+ pub fn from_bytes ( bytes : & [ u8 ] ) -> Result < Self > {
498+ let Some ( first) = bytes . first ( ) . copied ( ) else {
499499 bail ! ( "Empty attestation bytes" ) ;
500500 } ;
501501 if first == 0x00 {
502- let legacy = LegacyVersionedAttestation :: decode ( & mut & scale [ ..] )
502+ let legacy = LegacyVersionedAttestation :: decode ( & mut & bytes [ ..] )
503503 . context ( "Failed to decode legacy VersionedAttestation" ) ?;
504504 return match legacy {
505505 LegacyVersionedAttestation :: V0 { attestation } => Ok ( Self :: V0 { attestation } ) ,
506506 } ;
507507 }
508508 if is_cbor_map_prefix ( first) {
509- let attestation = AttestationV1 :: from_cbor ( scale ) ?;
509+ let attestation = AttestationV1 :: from_cbor ( bytes ) ?;
510510 return Ok ( Self :: V1 { attestation } ) ;
511511 }
512- if first == 0x01 && scale . get ( 1 ) . is_some_and ( |byte| is_cbor_map_prefix ( * byte) ) {
513- let attestation = AttestationV1 :: from_cbor ( & scale [ 1 ..] ) ?;
512+ if first == 0x01 && bytes . get ( 1 ) . is_some_and ( |byte| is_cbor_map_prefix ( * byte) ) {
513+ let attestation = AttestationV1 :: from_cbor ( & bytes [ 1 ..] ) ?;
514514 return Ok ( Self :: V1 { attestation } ) ;
515515 }
516516 bail ! ( "Unknown attestation wire format" ) ;
517517 }
518518
519519 /// Encode versioned attestation bytes.
520- pub fn to_scale ( & self ) -> Vec < u8 > {
520+ pub fn to_bytes ( & self ) -> Vec < u8 > {
521521 match self {
522522 Self :: V0 { attestation } => LegacyVersionedAttestation :: V0 {
523523 attestation : attestation. clone ( ) ,
@@ -529,6 +529,16 @@ impl VersionedAttestation {
529529 }
530530 }
531531
532+ #[ doc( hidden) ]
533+ pub fn from_scale ( bytes : & [ u8 ] ) -> Result < Self > {
534+ Self :: from_bytes ( bytes)
535+ }
536+
537+ #[ doc( hidden) ]
538+ pub fn to_scale ( & self ) -> Vec < u8 > {
539+ self . to_bytes ( )
540+ }
541+
532542 /// Try to project any version into the legacy attestation structure.
533543 pub fn try_into_inner ( self ) -> Result < Attestation > {
534544 match self {
@@ -1206,9 +1216,9 @@ mod tests {
12061216 let payload = r#"{"pod_uid":"abc","workload_id":"default/app"}"# . to_string ( ) ;
12071217 let encoded = dummy_tdx_attestation ( report_data)
12081218 . into_versioned_with_report_data_payload ( payload. clone ( ) )
1209- . to_scale ( ) ;
1219+ . to_bytes ( ) ;
12101220 assert ! ( matches!( encoded. first( ) , Some ( 0xa0 ..=0xbf ) ) ) ;
1211- let decoded = VersionedAttestation :: from_scale ( & encoded) . expect ( "decode attestation" ) ;
1221+ let decoded = VersionedAttestation :: from_bytes ( & encoded) . expect ( "decode attestation" ) ;
12121222 assert_eq ! ( decoded. report_data_payload( ) , Some ( payload. as_str( ) ) ) ;
12131223 assert_eq ! ( decoded. clone( ) . into_inner( ) . report_data, report_data) ;
12141224 let VersionedAttestation :: V1 { attestation } = decoded else {
0 commit comments