C quickstart example
examples/c/quickstart.c is a complete C11 program that:
- parses a schema from UTF-8 YAML into a
PredsyncSet; - constructs an
Encoderfor message 0; - prepares one
PredsyncValueper field; - encodes a frame into a caller-owned byte array;
- constructs a
Decoder, feeds the frame, and reads decoded metadata; - frees every handle in reverse order.
The program is compiled by the C ABI harness with -Wall -Wextra -Werror, so
the example cannot silently drift from the header. It is also run as part of
pixi run c-abi and therefore pixi run check.
pixi run c-abi
The example deliberately uses only the generated public header. It does not include internal Rust headers or link directly to compiler internals.
For variable-length fields, PredsyncValue::ptr is borrowed on encode and must
remain valid for the duration of predsync_encode. On decode, set cap to the
capacity of your own buffer; the library reports BufferTooSmall rather than
writing beyond it. See the C API reference.