diff --git a/tls_codec/derive/src/lib.rs b/tls_codec/derive/src/lib.rs index 63ebe0898..07abfad98 100644 --- a/tls_codec/derive/src/lib.rs +++ b/tls_codec/derive/src/lib.rs @@ -1061,7 +1061,7 @@ fn impl_deserialize_bytes(parsed_ast: TlsStruct) -> TokenStream2 { impl #impl_generics tls_codec::DeserializeBytes for #ident #ty_generics #where_clause { fn tls_deserialize_bytes(bytes: &[u8]) -> core::result::Result<(Self, &[u8]), tls_codec::Error> { #discriminant_constants - let (discriminant, remainder) = <#repr as tls_codec::DeserializeBytes>::tls_deserialize_bytes(bytes)?; + let (discriminant, remainder) = #repr::tls_deserialize_bytes(bytes)?; match discriminant { #(#arms)* _ => { diff --git a/tls_codec/derive/tests/decode.rs b/tls_codec/derive/tests/decode.rs index 698ee0c40..93d5fa430 100644 --- a/tls_codec/derive/tests/decode.rs +++ b/tls_codec/derive/tests/decode.rs @@ -1,6 +1,7 @@ #![cfg(feature = "std")] use tls_codec::{ - Deserialize, Error, Serialize, Size, TlsSliceU16, TlsVecU16, TlsVecU32, TlsVecU8, VLBytes, + Deserialize, DeserializeBytes, Error, Serialize, Size, TlsSliceU16, TlsVecU16, TlsVecU32, + TlsVecU8, VLBytes, }; use tls_codec_derive::{TlsDeserialize, TlsDeserializeBytes, TlsSerialize, TlsSize}; @@ -58,10 +59,7 @@ fn tuple_struct() { let serialized_t1 = t1.tls_serialize_detached().unwrap(); let deserialized_t1 = TupleStruct1::tls_deserialize(&mut serialized_t1.as_slice()).unwrap(); let (deserialized_bytes_t1, _remainder) = - ::tls_deserialize_bytes( - serialized_t1.as_slice(), - ) - .unwrap(); + TupleStruct1::tls_deserialize_bytes(serialized_t1.as_slice()).unwrap(); assert_eq!(t1, deserialized_t1); assert_eq!(t1, deserialized_bytes_t1); assert_eq!( @@ -77,10 +75,7 @@ fn tuple_struct() { let serialized_t2 = t2.tls_serialize_detached().unwrap(); let deserialized_t2 = TupleStruct::tls_deserialize(&mut serialized_t2.as_slice()).unwrap(); let (deserialized_bytes_t2, _remainder) = - ::tls_deserialize_bytes( - serialized_t2.as_slice(), - ) - .unwrap(); + TupleStruct::tls_deserialize_bytes(serialized_t2.as_slice()).unwrap(); assert_eq!(t2, deserialized_t2); assert_eq!(t2, deserialized_bytes_t2); assert_eq!( @@ -98,8 +93,7 @@ fn simple_enum() { let b = &[0u8, 5] as &[u8]; let mut b_reader = b; let deserialized = ExtensionType::tls_deserialize(&mut b_reader).unwrap(); - let (deserialized_bytes, _remainder) = - ::tls_deserialize_bytes(b).unwrap(); + let (deserialized_bytes, _remainder) = ExtensionType::tls_deserialize_bytes(b).unwrap(); assert_eq!(ExtensionType::RatchetTree, deserialized); assert_eq!(ExtensionType::RatchetTree, deserialized_bytes); @@ -113,8 +107,7 @@ fn simple_enum() { for variant in variants.iter() { let deserialized = ExtensionType::tls_deserialize(&mut b_reader).unwrap(); assert_eq!(variant, &deserialized); - let (deserialized_bytes, remainder) = - ::tls_deserialize_bytes(b).unwrap(); + let (deserialized_bytes, remainder) = ExtensionType::tls_deserialize_bytes(b).unwrap(); b = remainder; assert_eq!(variant, &deserialized_bytes); } @@ -133,11 +126,9 @@ fn deserialize_tls_vec() { assert_eq!(long_vector.len(), deserialized_long_vec.len()); assert_eq!(long_vector, deserialized_long_vec); let (deserialized_long_vec_bytes, _remainder): (Vec, &[u8]) = - as tls_codec::DeserializeBytes>::tls_deserialize_bytes( - serialized_long_vec.as_slice(), - ) - .map(|(v, r)| (v.into(), r)) - .unwrap(); + TlsVecU16::::tls_deserialize_bytes(serialized_long_vec.as_slice()) + .map(|(v, r)| (v.into(), r)) + .unwrap(); assert_eq!(long_vector.len(), deserialized_long_vec_bytes.len()); assert_eq!(long_vector, deserialized_long_vec_bytes); }