Embed Styx schemas in binaries for zero-execution discovery.
This crate provides macros to embed schemas in your binary, and functions to extract them without executing the binary. This enables tooling (LSP, CLI) to discover schemas safely.
Embedding schemas
Each schema must have a meta { id ... } block. The ID is used to generate
a unique static name, allowing multiple schemas to coexist in the same binary.
Inline strings
embed_inline!;
From files
// Single file (path relative to crate root)
embed_file!;
// Multiple files (each becomes its own embedded schema)
embed_files!;
Generated from types (build script pattern)
For schemas derived from Rust types using facet-styx, use a build script:
// build.rs
// src/main.rs
embed_outdir_file!;
This keeps the schema in sync with your types automatically.
Binary format (V2)
Each embedded schema is stored as its own blob:
STYX_SCHEMA_V2\0\0 // 16 bytes magic
<decompressed_len:u32le>
<compressed_len:u32le>
<blake3:32bytes> // hash of decompressed content
<lz4 compressed schema>
Multiple schemas in a binary means multiple blobs, each with its own magic header.
The schema's meta { id ... } is used to identify which schema is which.
Extracting schemas
use extract_schemas;
let schemas = extract_schemas?;
for schema in schemas