This crate provides convenience methods for reading and writing data to binary buffers. It supports writing primitive types, as well as Strings and Vectors to in-memory streams and files.
Installation
This crate works with Cargo and is on
crates.io. Add it to your Cargo.toml
like so:
[]
= "1"
If you want to write data to a buffer you do it like so:
use crate;
use Cursor;
let mut buffer = new;
buffer.write_u32?;
buffer.write_u32.unwrap?;
buffer.write_string?;
You can then return the full buffer as a vector:
let data = buffer.to_vec?;
Reading buffers is just as simple.
let mut reader = new;
let magic = reader.read_u32?;
let body = reader.read_string?;