Expand description
zserio serialization bindings for rust. zserio
is a binary
serialization language, similar to Protobuf. The key features are:
- It features a rich schema.
- Programming language agnostic.
- Compact and easy to use.
- Good and fast out-of the box compression.
The syntax is similar to C/C++, which makes zserio code easy to read.
Example:
struct DrinkOrder
{
string customerName;
string orderName;
bool addSugar;
bool addMilk;
uint32 price;
optional string extraWishes;
uint32 extraCharges;
function uint32 getTotal() {
return price + extraCharges;
};
};
Above code is zserio
code. Using the zserio
serialization bindings, this
code can be used to generate C++/Python/Java code to read/write
zserio
-encoded data. With this crate, it is now possible to read/write
zserio
-encoded binary data in rust. To generate Rust code for a zserio schema
you must first install zserio-rs-build
:
cargo install zserio-rs-build
Afterwards, you can run the code generator:
rust-rs-build --root=<code_root_path> -o=<output_directory> <path_to_zserio_files>
This will generate the interface files in rust, that allow reading/writing zserio-encoded data.
The --root
CLI flag is optional, and enforces an overall crate prefix to
the generated code.
The generated code is formatted, but does not match the exact standards from
rustfmt. If you are using rustfmt from the nightly channel you can set
format_generated_files = false
in rustfmt.toml
(see
rust-lang/rustfmt#5080.
Re-exports§
pub use ztype::ZserioPackableObject;
Modules§
Enums§
- Zserio
Error - Error enumeration of zserio errors.
Functions§
- bit_
length - from_
bytes - Deserialize an instance of
T
from data. - from_
file - Read an instance of
T
from a file. - from_
reader - Read an instance of
T
from a IO stream. - numbits
- Gets the minimum number of bits required to encode given number of different values.
- to_
bytes - Serialize an instance of
T
to a a byte vector - to_
writer - Serialize an instance of
T
to a writer instance
Type Aliases§
- Result
- Result type for zserio errors.