Crate bin_buffer

source ·
Expand description

This is a simple crate to read and write binairy data.

Example:

use bin_buffer::*;
let x = 16u16;
let y = String::from("hello");
let z = (0.0001f64,1.1111f64);
let mut buffer = Vec::new();
x.into_buffer(&mut buffer);
y.copy_into_buffer(&mut buffer);
z.into_buffer(&mut buffer);
let mut buffer = ReadBuffer::from_raw(buffer);
assert_eq!(Some(x), u16::from_buffer(&mut buffer));
assert_eq!(Some(y), String::from_buffer(&mut buffer));
assert_eq!(Some(z), <(f64,f64)>::from_buffer(&mut buffer));

Structs

Buffer from which we can read.

Traits

Object can be read and written to a Buffer

Functions

Just copies the content of the second buffer to the end of the first buffer.
Reads a buffer from a file.
Writes a buffer to a file. Will create a new file if none exists or overwrite otherwise.
Writes a buffer to the end of a file. Will create a new file if none exists.

Type Definitions

Buffer: a Vector of bytes