You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of std::io::Write, perhaps we could use a different trait that abstracts away appending data to a buffer (bytes::BufMut?). Using a trait instead of e.g. &mut Vec<u8> will let us to very easily implement size hints like here: #582 based on the existing serialize() method.
The RowSerializationContext should contain information about the bind markers: column names and their types. Later, we may add more stuff there.
As this change will affect all Session::query and Session::execute calls which should be ubiquitous in the user codebase, we should make it as easy as possible to migrate to the new API, preferably step by step.
Current serialization API is heavily based on SerializedValues type which is an untyped container for serialized values. Session::{execute,query} receive the argument list as an impl ValueList type - which is just a trait that allows to convert the type to SerializedValues. In general, we should implement SerializeRow for each type that implements ValueList, which also includes SerializedValues.
Calls like session.execute(&prepared, (1, 2, 3)) should work automatically out of the box as we will implement SerializeRow for types that implement SerializedValues, and SerializeCql for types that implement Value. This should be the most common case.
In a generic context like session.execute(&prepared, generic_list) where generic_list: impl ValueList, the piece of code should be adjusted so that generic_list.serialized()? is called instead - which will convert to SerializedValues which does implement the new SerializedRow.
For the case of user impls of ValueList and Value, we can provide macros (not necessarily procedural) that generate a SerializedRow/SerializedCql implementation based on the existing ValueList/Value.
It will be necessary to update some examples and documentation, but I don't expect it to be much work compared to the deserialization refactor.
The content you are editing has changed. Please copy your edits and refresh the page.
The issue #802 depends on the SerializeRow and SerializeCql traits introduced by this task. I think just those traits + impls of 2-3 trivial types should be added first, in a separate PR in order to unblock it.
Definitions of the traits have been merged to main (#819). To complete the task, we further need to:
Implement the new traits for the existing types that support Value and ValueList (except for macros for UDTs, those are covered in Serialization refactor: macros for the new traits #802) - can be split over several PRs if needed,
Adjust the codebase to use the new serialization traits instead of the old ones (Session::query, Session::execute, _iter versions, etc.).
Sub-task of #463.
Let's use the convention introduced in the not-yet-done deserialization refactor and let's name the new traits
SerializeCql
andSerializeRow
:Instead of
std::io::Write
, perhaps we could use a different trait that abstracts away appending data to a buffer (bytes::BufMut
?). Using a trait instead of e.g.&mut Vec<u8>
will let us to very easily implement size hints like here: #582 based on the existingserialize()
method.The
RowSerializationContext
should contain information about the bind markers: column names and their types. Later, we may add more stuff there.As this change will affect all
Session::query
andSession::execute
calls which should be ubiquitous in the user codebase, we should make it as easy as possible to migrate to the new API, preferably step by step.Current serialization API is heavily based on
SerializedValues
type which is an untyped container for serialized values.Session::{execute,query}
receive the argument list as animpl ValueList
type - which is just a trait that allows to convert the type toSerializedValues
. In general, we should implementSerializeRow
for each type that implementsValueList
, which also includesSerializedValues
.session.execute(&prepared, (1, 2, 3))
should work automatically out of the box as we will implementSerializeRow
for types that implementSerializedValues
, andSerializeCql
for types that implementValue
. This should be the most common case.session.execute(&prepared, generic_list)
wheregeneric_list: impl ValueList
, the piece of code should be adjusted so thatgeneric_list.serialized()?
is called instead - which will convert toSerializedValues
which does implement the newSerializedRow
.ValueList
andValue
, we can provide macros (not necessarily procedural) that generate aSerializedRow
/SerializedCql
implementation based on the existingValueList
/Value
.It will be necessary to update some examples and documentation, but I don't expect it to be much work compared to the deserialization refactor.
Tasks
SerializeRow
andSerializeCql
for current implementors ofValueList
andValue
#821SerializeRow
andSerializeCql
in the public API #822The text was updated successfully, but these errors were encountered: