Need help with binread?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

jam1garner
198 Stars 17 Forks MIT License 236 Commits 7 Opened issues

Description

A Rust crate for helping parse structs from binary data using ✨macro magic✨

Services available

!
?

Need anything else?

Contributors list

# 5,433
JavaScr...
dojo
HTML
jQuery
147 commits
# 334,026
Rust
C++
Shell
modding
53 commits
# 196,624
Rust
C++
argumen...
argumen...
6 commits
# 49,361
C
Shell
GNU Gen...
osdev
6 commits
# 36,855
Gradle
Kotlin
opencl
Babel
2 commits
# 26,375
forth
Sass
linux-d...
wacom
1 commit
# 267,391
Shell
elm
aho-cor...
Visual ...
1 commit
# 369,868
C#
modding
Rust
Shell
1 commit
# 22,462
Less
kotlin-...
packets
gitlab-...
1 commit
# 235,705
kafka
rust-la...
electra
network...
1 commit
# 253,799
Shell
golang
Linux
TeX
1 commit

binread

tests docs.rs codecov discord matrix: #binrw:matrix.org

A Rust crate for helping parse structs from binary data using ✨macro magic✨

Usage

BinRead uses a derive macro for declaratively defining binary parsing methods for structs.

#[derive(BinRead)]
#[br(magic = b"DOG", assert(name.len() != 0))]
struct Dog {
    bone_pile_count: u8,

#[br(big, count = bone_pile_count)]
bone_piles: Vec<u16>,

#[br(align_before = 0xA)]
name: NullString

}

let mut reader = Cursor::new(b"DOG\x02\x00\x01\x00\x12\0\0Rudy\0"); let dog: Dog = reader.read_ne().unwrap(); assert_eq!(dog.bone_piles, &[0x1, 0x12]); assert_eq!(dog.name.into_string(), "Rudy")

More documentation can be found here

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.