Skip to content
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

Write all #172

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/simple/universal/z_simple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ struct CustomCodec {
static Bytes serialize(const CustomStruct& s) {
Bytes b;
auto writer = b.writer();
writer.write(serialize_arithmetic(s.u).data(), 4);
writer.write(serialize_arithmetic(s.d).data(), 8);
writer.write(reinterpret_cast<const uint8_t*>(s.s.data()), s.s.size());
writer.write_all(serialize_arithmetic(s.u).data(), 4);
writer.write_all(serialize_arithmetic(s.d).data(), 8);
writer.write_all(reinterpret_cast<const uint8_t*>(s.s.data()), s.s.size());
return b;
}

Expand Down
4 changes: 2 additions & 2 deletions include/zenoh/api/bytes.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ class Bytes : public Owned<::z_owned_bytes_t> {
/// @param len number of bytes to copy from src to the underlying ``Bytes`` instance.
/// @param res if not null, the result code will be written to this location, otherwise ZException exception
/// will be thrown in case of error.
void write(const uint8_t* src, size_t len, ZResult* err = nullptr) {
__ZENOH_RESULT_CHECK(::z_bytes_writer_write(this->loan(), src, len), err, "Failed to write data");
void write_all(const uint8_t* src, size_t len, ZResult* err = nullptr) {
__ZENOH_RESULT_CHECK(::z_bytes_writer_write_all(this->loan(), src, len), err, "Failed to write data");
}
};

Expand Down
14 changes: 7 additions & 7 deletions tests/universal/bytes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void reader_writer() {
Bytes b;
{
auto writer = b.writer();
writer.write(data.data(), 5);
writer.write(data.data() + 5, 5);
writer.write_all(data.data(), 5);
writer.write_all(data.data() + 5, 5);
}

auto reader = b.reader();
Expand All @@ -46,8 +46,8 @@ void reader_seek_tell() {
Bytes b;
{
auto writer = b.writer();
writer.write(data.data(), 5);
writer.write(data.data() + 5, 5);
writer.write_all(data.data(), 5);
writer.write_all(data.data() + 5, 5);
}

auto reader = b.reader();
Expand Down Expand Up @@ -211,9 +211,9 @@ struct CustomCodec {
static Bytes serialize(const CustomStruct& s) {
Bytes b;
auto writer = b.writer();
writer.write(serialize_arithmetic(s.u).data(), 4);
writer.write(serialize_arithmetic(s.d).data(), 8);
writer.write(reinterpret_cast<const uint8_t*>(s.s.data()), s.s.size());
writer.write_all(serialize_arithmetic(s.u).data(), 4);
writer.write_all(serialize_arithmetic(s.d).data(), 8);
writer.write_all(reinterpret_cast<const uint8_t*>(s.s.data()), s.s.size());
return b;
}

Expand Down
Loading