Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

C quickstart example

examples/c/quickstart.c is a complete C11 program that:

  1. parses a schema from UTF-8 YAML into a PredsyncSet;
  2. constructs an Encoder for message 0;
  3. prepares one PredsyncValue per field;
  4. encodes a frame into a caller-owned byte array;
  5. constructs a Decoder, feeds the frame, and reads decoded metadata;
  6. 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.