Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jam1garner authored Nov 2, 2019
1 parent ccd0684 commit 2fc4648
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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

```rust
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]);
}
```

0 comments on commit 2fc4648

Please sign in to comment.