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§

ReadBuffer
Buffer from which we can read.

Traits§

Bufferable
Object can be read and written to a Buffer

Functions§

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

Type Aliases§

Buffer
Buffer: a Vector of bytes