#buffer #io #data #bin #object #read #f64

bin_buffer

A simple library for writing objects to binairy buffers

1 unstable release

0.1.12 Nov 18, 2022
0.1.11 May 7, 2020
0.1.10 Mar 31, 2020

#363 in Parser tooling

33 downloads per month

MIT license

23KB
427 lines

docs

BinBuffer

Simple lightweight crate for translating objects into binairy buffers. It supports reading and writing these types: u64, u32, u16, u8, f64, f32, (f64,f64), String, Vec<Bufferable + Clone>, (U,V), (U,V,W), (U,V,W,X) where U,V,W are Bufferable. 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));

lib.rs:

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));

No runtime deps