-
Notifications
You must be signed in to change notification settings - Fork 75
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
serialization refactoring #691
Conversation
PR missing one of the required labels: {'internal', 'enhancement', 'documentation', 'breaking-change', 'dependencies', 'bug', 'new feature'} |
84edafb
to
e772f8d
Compare
d357eb8
to
b406fe7
Compare
|
examples/unix/c11/z_bytes.c
Outdated
z_string_from_str(&kvs_input[1].value, "def", NULL, NULL); | ||
|
||
z_bytes_writer_t writer = z_bytes_get_writer(z_loan_mut(payload)); | ||
z_bytes_writer_serialize_sequence_begin(&writer, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sequence but not e.g. array or list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it can be used for any sequence/container (i.e. list/array/set/map etc). Mostly to choose something neutral to have something similar to iterate notion.
examples/unix/c11/z_bytes.c
Outdated
z_bytes_reader_deserialize_sequence_begin(&reader, &num_elements1); | ||
assert(num_elements1 == 3); | ||
for (size_t j = 0; j < 3; ++j) { | ||
z_bytes_reader_deserialize_uint64(&reader, &u); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happens there if we try deserialize more elements that was serialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deserialize function calls will return a error if we run out of bytes to read, otherwise there are no any checks so it is up to the user to ensure he serializes/deserializes data correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need to provide at least some protection or checks, but this can be done later, the main thing is that we have a returned error code, which we can then expand.
examples/unix/c11/z_bytes.c
Outdated
z_bytes_reader_deserialize_uint64(&reader, &u); | ||
assert(u == cs.u[i][j]); | ||
} | ||
z_bytes_reader_deserialize_sequence_end(&reader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happens there if we try deserialize less elements that was serialized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing, there is no fast way to check because user can serialize tuples which would involve more serialize calls than number of elements.
Co-authored-by: Alexander Bushnev <sashacmc@gmail.com>
As discussed we do not need z_bytes_writer_serialize_sequence_end now, but might require it for future optimizations. Yes we support sequence of sequences. |
add ze_serializer_from/to_writer and ze_deserializer_from/to_reader;
2307636
to
cea6730
Compare
add ze_serializer_from/to_writer and ze_deserializer_from/to_reader;
serialization refactoring
Related to eclipse-zenoh/zenoh#1472