Skip to content

Commit

Permalink
serialize: deduplicate do_serialize[_err]
Browse files Browse the repository at this point in the history
  • Loading branch information
wprzytula committed May 21, 2024
1 parent 8065379 commit 5c71314
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scylla-cql/src/types/serialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,17 +1574,21 @@ mod tests {
assert_eq!(typed_data, erased_data);
}

fn do_serialize<T: SerializeCql>(t: T, typ: &ColumnType) -> Vec<u8> {
fn do_serialize_result<T: SerializeCql>(
t: T,
typ: &ColumnType,
) -> Result<Vec<u8>, SerializationError> {
let mut ret = Vec::new();
let writer = CellWriter::new(&mut ret);
t.serialize(typ, writer).unwrap();
ret
t.serialize(typ, writer).map(|_| ()).map(|()| ret)
}

fn do_serialize<T: SerializeCql>(t: T, typ: &ColumnType) -> Vec<u8> {
do_serialize_result(t, typ).unwrap()
}

fn do_serialize_err<T: SerializeCql>(t: T, typ: &ColumnType) -> SerializationError {
let mut ret = Vec::new();
let writer = CellWriter::new(&mut ret);
t.serialize(typ, writer).unwrap_err()
do_serialize_result(t, typ).unwrap_err()
}

#[test]
Expand Down

0 comments on commit 5c71314

Please sign in to comment.