diff --git a/scylla-cql/src/frame/value.rs b/scylla-cql/src/frame/value.rs index 9cc482c286..9e927be3a3 100644 --- a/scylla-cql/src/frame/value.rs +++ b/scylla-cql/src/frame/value.rs @@ -504,6 +504,12 @@ impl Value for &str { } impl Value for Vec { + fn serialize(&self, buf: &mut Vec) -> Result<(), ValueTooBig> { + <&[u8] as Value>::serialize(&self.as_slice(), buf) + } +} + +impl Value for &[u8] { fn serialize(&self, buf: &mut Vec) -> Result<(), ValueTooBig> { let val_len: i32 = self.len().try_into().map_err(|_| ValueTooBig)?; buf.put_i32(val_len); diff --git a/scylla-cql/src/frame/value_tests.rs b/scylla-cql/src/frame/value_tests.rs index 9564146426..f7e480362f 100644 --- a/scylla-cql/src/frame/value_tests.rs +++ b/scylla-cql/src/frame/value_tests.rs @@ -35,6 +35,12 @@ fn u8_array_serialization() { assert_eq!(serialized(val), vec![0, 0, 0, 4, 1, 1, 1, 1]); } +#[test] +fn u8_slice_serialization() { + let val = vec![1u8, 1, 1, 1]; + assert_eq!(serialized(val.as_slice()), vec![0, 0, 0, 4, 1, 1, 1, 1]); +} + #[test] fn naive_date_serialization() { // 1970-01-31 is 2^31