Skip to content

Commit

Permalink
remove remaining qualifications
Browse files Browse the repository at this point in the history
  • Loading branch information
kkohbrok committed Nov 14, 2023
1 parent dafed07 commit 77c1297
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tls_codec/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*
_ => {
Expand Down
27 changes: 9 additions & 18 deletions tls_codec/derive/tests/decode.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -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) =
<TupleStruct1 as tls_codec::DeserializeBytes>::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!(
Expand All @@ -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) =
<TupleStruct as tls_codec::DeserializeBytes>::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!(
Expand All @@ -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) =
<ExtensionType as tls_codec::DeserializeBytes>::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);

Expand All @@ -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) =
<ExtensionType as tls_codec::DeserializeBytes>::tls_deserialize_bytes(b).unwrap();
let (deserialized_bytes, remainder) = ExtensionType::tls_deserialize_bytes(b).unwrap();
b = remainder;
assert_eq!(variant, &deserialized_bytes);
}
Expand All @@ -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<ExtensionStruct>, &[u8]) =
<TlsVecU16<ExtensionStruct> as tls_codec::DeserializeBytes>::tls_deserialize_bytes(
serialized_long_vec.as_slice(),
)
.map(|(v, r)| (v.into(), r))
.unwrap();
TlsVecU16::<ExtensionStruct>::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);
}
Expand Down

0 comments on commit 77c1297

Please sign in to comment.