Closed Gor027 closed 2 months ago
@wprzytula @Lorak-mmk Ping for review.
A general idea to make the logic more type-safe (which Rust promotes): replace groups of
Option
s with custom types that encode the logic inside themselves (their names, variants, etc.). E.g. in case ofCassResultIterator
,position
isNone
iffrow
isNone
. This dependency could be represented as an enum:pub struct CassResultIterator { result: Arc<CassResult>, curr_row_info: CassResultIteratorCurrentRowInfo, } enum CassResultIteratorCurrentRowInfo { NoRows, Rows { current_row: CassRow, position: usize, } }
I like the idea to express the state of the fields of iterators through enums, but that will make this PR a lot more complicated. Do you mind doing this refactor in another PR? I will open an issue to not forget it.
A general idea to make the logic more type-safe (which Rust promotes): replace groups of
Option
s with custom types that encode the logic inside themselves (their names, variants, etc.). E.g. in case ofCassResultIterator
,position
isNone
iffrow
isNone
. This dependency could be represented as an enum:pub struct CassResultIterator { result: Arc<CassResult>, curr_row_info: CassResultIteratorCurrentRowInfo, } enum CassResultIteratorCurrentRowInfo { NoRows, Rows { current_row: CassRow, position: usize, } }
I like the idea to express the state of the fields of iterators through enums, but that will make this PR a lot more complicated. Do you mind doing this refactor in another PR? I will open an issue to not forget it.
I'd prefer to have the refactor done in this PR. You can put it in a separate commit.
A general idea to make the logic more type-safe (which Rust promotes): replace groups of
Option
s with custom types that encode the logic inside themselves (their names, variants, etc.). E.g. in case ofCassResultIterator
,position
isNone
iffrow
isNone
. This dependency could be represented as an enum:pub struct CassResultIterator { result: Arc<CassResult>, curr_row_info: CassResultIteratorCurrentRowInfo, } enum CassResultIteratorCurrentRowInfo { NoRows, Rows { current_row: CassRow, position: usize, } }
I have applied the idea in separate commits. Perhaps this approach is more expressive and makes it easy to understand the iterator's state, although it looks overhead to me.
Looking at the maze of
if
s, I'm convinced that a set of unit tests for deserialization is absolutely required.
I added some relevant tests for collection iterators as Cassandra tests may not cover everything.
I think we can safely close this.
Oops, wrong PR
After all I think we can close this - applying new deserialization to cpp-rust-driver will require at least some changes to this PR, so it will have to be done by someone else.
Pre-review checklist
Fixes #94
This PR Integrates the new deserialization API from the Rust driver which is a WIP. It is dependent upon the execution profiles' PR #107 and can be merged only after the latter is already done. The lazy deserialization allows to also implement binder makers for decimal and duration types. The
test_cassandra_types
tests for these types are also enabled..github/workflows/build.yml
ingtest_filter
..github/workflows/cassandra.yml
ingtest_filter
.