Skip to main content

Module schema

Module schema 

Source
Expand description

ZAP Schema Compiler

Inspired by Cap’n Proto’s zero-copy serialization approach, the ZAP Schema Compiler provides a unified schema language with two supported syntaxes:

  • .zap (default) - Whitespace-significant, clean minimal syntax
  • .capnp (compatible) - Backwards-compatible with existing Cap’n Proto schemas

The .zap syntax is the recommended format for all new schemas, offering cleaner, more readable definitions where ordering determines field ordinals.

# ZAP Schema - clean and minimal
# Colons and semicolons are auto-inserted by the compiler

struct Person
  name Text
  age UInt32
  email Text
  address Address

struct Address
  street Text
  city Text
  zip Text

enum Status
  pending
  active
  completed

interface Greeter
  sayHello (name Text) -> (greeting Text)
  sayGoodbye (name Text) -> ()

§Cap’n Proto Compatibility

For migration purposes, the compiler also accepts .capnp files with standard Cap’n Proto syntax including explicit ordinals (@0, @1, etc.) and brace-delimited blocks. This allows gradual migration from existing Cap’n Proto schemas to the cleaner ZAP format.

Structs§

ZapSchema
ZAP schema compiler

Enums§

SchemaFormat
Schema format type

Functions§

capnp_to_zap
Convert .capnp source to .zap whitespace format
compile_to_rust
Compile .zap source to Rust code
migrate_capnp_to_zap
Convert a .capnp file to .zap file
transpile
Compile a .zap file
transpile_str
Compile .zap source string