Crates.io | bin_buffer |
lib.rs | bin_buffer |
version | 0.1.12 |
source | src |
created_at | 2020-03-10 11:43:35.919229 |
updated_at | 2022-11-18 14:31:30.040199 |
description | A simple library for writing objects to binairy buffers. |
homepage | |
repository | https://gitlab.com/codybloemhard/bin-buffer |
max_upload_size | |
id | 217234 |
size | 24,372 |
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.
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));