scylladb / cpp-rust-driver

API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver.
GNU Lesser General Public License v2.1
16 stars 11 forks source link

ser: use rust-driver's builtin serialization for simple types #152

Closed muzarski closed 4 months ago

muzarski commented 4 months ago

Previously, we would reimplement a serialization logic. It was a copy from rust driver, with the typechecks excluded.

In this PR, we get rid of the repeated code. To skip the typechecks (or rather, to make the typechecks always pass), we simply provide a valid ColumnType to SerializeValue::serialize().

This is a kind of hack, but thanks to that we don't have to reimplement serialization logic.

Pre-review checklist

muzarski commented 4 months ago

Isn't it possible to remove CassCqlValue entirely?

I think it is possible. The main obstacle are udts, collections and tuples. We would need to construct a valid ColumnType for each of these, and a nested ColumnType may be expensive to construct (some allocations). I think that there is no other way to use a builtin rust-driver's serialization with typechecks skipped for these types.

Lorak-mmk commented 4 months ago

Ok, let's keep the approach from this PR

muzarski commented 4 months ago

Actually, I think we could simply have a wrapper over CqlValue.

muzarski commented 4 months ago

Actually, I think we could simply have a wrapper over CqlValue.

Give me a second, I'll investigate it and update this PR in case it's possible.

muzarski commented 4 months ago

Nvm, I don't think there is much sense to introduce a wrapper over CqlValue, since we would need to match variants that can never be created via cpp-rust-driver API (e.g. there is no way to create a CqlValue::Counter() value).

I think that we can merge it as is.