Closed milyin closed 1 month ago
After discussion with @DenisBiryukov91 the following plan was proposed:
z_owned_bytes_writer_t
. The construction of the writer (in append case) consumes z_owned_bytes_t
with move operation. This guarantees that no other writer can be created for the same ZBytes. After finishing writing the function e.g. z_close_writer
which consumes writer and constructs updated z_owned_bytes_t
should be calledz_slice_iterator_t
. It's copyable, multiple readers for same z_owned_bytes_t
are allowedThis proposal is similar to this attempt to fix the same issue in https://github.com/eclipse-zenoh/zenoh-c/pull/675
Describe the release item
The types
z_bytes_writer_t
,z_bytes_reader_t
are copyable according to their names. But they wraps Rust typesZBytesWriter
/ZBytesReader
which are not copyable. The behavior of parallel reading/writing to multiple readers/writers is not defined. There should be one and only one reader or writer forz_owned_bytes_t
at any moment. So we have to:z_bytes_writer_t
,z_bytes_reader_t
owned to protect from copyingz_owned_bytes_writer_t
if another one exists