Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 958 Bytes

binary.md

File metadata and controls

35 lines (25 loc) · 958 Bytes

Tagged Binary Messages (Crusher)

Glaze provides a tagged binary format to send and receive messages like JSON, but with significantly improved performance and message size savings.

The binary specification is known as Crusher.

Write Binary

my_struct s{};
std::vector<std::byte> buffer{};
glz::write_binary(s, buffer);

Read Binary

my_struct s{};
glz::read_binary(s, buffer);

Partial Objects

It is sometimes desirable to write out only a portion of an object. This is permitted via an array of JSON pointers, which indicate which parts of the object should be written out.

static constexpr auto partial = glz::json_ptrs("/i",
                                               "/d",
                                               "/sub/x",
                                               "/sub/y");
std::vector<std::byte> out;
glz::write_binary<partial>(s, out);