-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
value: Cql[Varint/Decimal]Borrowed
#1148
value: Cql[Varint/Decimal]Borrowed
#1148
Conversation
I believe this is more readable, and should simplify the diff from the following commit.
This is a native representation of varint that holds borrowed bytes. Implemented SerializeValue and DeserializeValue for new type.
Has the same semantics as CqlDecimal, but borrows the bytes.
f3fc875
to
5808f5a
Compare
|
Now that I think of it: can we just use Bytes for CqlVarint? The only downside I see is that it would make the whole frame alive as long as CqlVarint is alive, but it is also the case for CqlVarintBorrowed (as it borrows the frame) - the only difference is that the latter is enforced at compile time, but complicates the code. This is a tradeoff, and I'm not sure which solution is better. |
I like this idea. This simplifies code by a lot. |
5808f5a
to
b76399f
Compare
I applied @Lorak-mmk suggestion - replaced |
b76399f
to
5808f5a
Compare
Reverted the changes with |
This PR introduces borrowed versions of CqlDecimal and CqlVarint. It implements SerializeValue and DeserializeValue for new types.
There is a use case for this in cpp-rust-driver - we need to set the pointer user provided, so it points to the underlying data. After lazy-deserialization refactor in cpp-rust-driver, CqlDecimal is not useful anymore. If we deserialize to CqlDecimal, it owns the bytes and is a stack variable - thus, we cannot set the pointer to its underlying data (it will be freed after function call).
Questions for reviewers:
From<Cql[Varint/Decimal]Borrowed> for Big[Int/Decimal]
. I didn't implement conversions in other direction, since new types borrow bytes (and From consumes). Do you think it's ok to make an exception here, and implementFrom<&Big[Int/Decimal]>
(from reference)?Pre-review checklist
./docs/source/
.[ ] I added appropriateFixes:
annotations to PR description.