Crate kaitai[][src]

Expand description

This crate is still very much a work in progress; it has a very limited feature set.

A macro for compiling Kaitai Struct into Rust.


Given the following file basic_be.ksy:

  id: basic
  endian: be
  - id: header
    type: u2
  - id: body
    type: s8
  - id: tail
    type: u4

The rust code to read a basic_be buffer would look something like this:

struct BasicBigEndian;

fn main() -> Result<()> {
    let file = BasicBigEndian::from_file("tests/files/example.basic")?;

    println!("head: {}", file.body);
    println!("body: {}", file.body);
    println!("tail: {}", file.body);


The filepath provided to kaitai_source is taken relative to the current file, similarly to how modules are found. However, the filepath provided to from_file is taken relative to the root of the project, like std::fs::File::open.


Module containing the traits implemented by the kaitai_source macro.


Enum representing the potential errors emitted by this crate.

Type Definitions

The type returned by KaitaiStruct functions.

Attribute Macros

See crate-level documentation for information on how to use this macro.