Skip to content

A Rust crate for helping write structs as binary data using ✨macro magic✨

License

Notifications You must be signed in to change notification settings

jam1garner/binwrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

binwrite

A Rust crate for helping write structs as binary data using ✨macro magic✨

Usage

The idea behind binwrite is using a derive macro for declaratively defining binary writing.

Basic Example

use binwrite::BinWrite;

#[derive(BinWrite)]
struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let point = Point { x: 1, y: -2 };
    let mut bytes = vec![];
    point.write(&mut bytes).unwrap();

    assert_eq!(bytes, vec![1, 0, 0, 0, 0xFE, 0xFF, 0xFF, 0xFF]);
}

more examples can be found in the BinWrite documentation.

About

A Rust crate for helping write structs as binary data using ✨macro magic✨

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages