Crates.io | kaitai |
lib.rs | kaitai |
version | |
source | src |
created_at | 2021-07-11 12:51:26.898965 |
updated_at | 2021-08-09 11:03:10.996932 |
description | A macro for compiling Kaitai Struct into Rust. |
homepage | |
repository | https://www.github.com/tsoutsman/kaitai-rs |
max_upload_size | |
id | 421398 |
Cargo.toml error: | TOML parse error at line 19, column 10 | 19 | readme = true | ^^^^ invalid type: boolean `true`, expected a string |
size | 0 |
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
:
meta:
id: basic
endian: be
seq:
- 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:
#[kaitai_source("../tests/formats/basic_be.ksy")]
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
.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.