diff --git a/serdect/src/slice.rs b/serdect/src/slice.rs index ee47062f0..9ff8b27c8 100644 --- a/serdect/src/slice.rs +++ b/serdect/src/slice.rs @@ -21,7 +21,7 @@ where if serializer.is_human_readable() { crate::serialize_hex::<_, _, false>(value, serializer) } else { - value.as_ref().serialize(serializer) + serializer.serialize_bytes(value.as_ref()) } } @@ -35,7 +35,7 @@ where if serializer.is_human_readable() { crate::serialize_hex::<_, _, true>(value, serializer) } else { - value.as_ref().serialize(serializer) + serializer.serialize_bytes(value.as_ref()) } } diff --git a/serdect/tests/cbor.rs b/serdect/tests/cbor.rs index 23bb0b693..a4173c69e 100644 --- a/serdect/tests/cbor.rs +++ b/serdect/tests/cbor.rs @@ -12,10 +12,12 @@ use serdect::{array, slice}; const EXAMPLE_BYTES: [u8; 16] = hex!("000102030405060708090A0B0C0D0E0F"); /// CBOR serialization of [`EXAMPLE_BYTES`] as a slice. -const CBOR_SLICE: [u8; 17] = hex!("90000102030405060708090A0B0C0D0E0F"); +/// (first three bits, `0b010` denote a byte string, and the last five, `0b10000` denote the length) +const CBOR_SLICE: [u8; 17] = hex!("50000102030405060708090A0B0C0D0E0F"); /// CBOR serialization of [`EXAMPLE_BYTES`] as an array. -const CBOR_ARRAY: [u8; 17] = CBOR_SLICE; +/// (first three bits, `0b100` denote an array, and the last five, `0b10000` denote the length) +const CBOR_ARRAY: [u8; 17] = hex!("90000102030405060708090A0B0C0D0E0F"); #[test] fn deserialize_slice() {