Crates.io | bin-it |
lib.rs | bin-it |
version | 1.2.0 |
source | src |
created_at | 2024-11-13 07:26:02.79219 |
updated_at | 2024-11-13 07:40:20.354411 |
description | Simple, efficient Rust library for binary serialization and deserialization |
homepage | https://github.com/aaiyer/bin-it |
repository | https://github.com/aaiyer/bin-it |
max_upload_size | |
id | 1446090 |
size | 22,896 |
Bin-It is a simple, efficient Rust library for binary serialization and deserialization. With a focus on performance and ease of use, Bin-It lets you seamlessly serialize Rust types into compact binary formats and read them back with precision. Whether you're storing data in binary files, transmitting data over networks, or handling low-level byte operations, Bin-It has you covered.
u8
, i16
, f32
, etc.).Vec<u8>
, Vec<f64>
, etc.).The BinaryWriter struct allows you to serialize various data types into a binary buffer:
use bin_it::BinaryWriter;
fn main() {
let mut writer = BinaryWriter::new();
writer.write_u32(42);
writer.write_string("Hello, Bin-It!");
writer.write_f64(3.14159);
let data = writer.get_data();
// Now `data` contains the binary representation of the serialized values.
}
The BinaryReader struct lets you deserialize the binary data back into Rust types:
use bin_it::BinaryReader;
fn main() {
let data = vec![42, /* binary data goes here */];
let mut reader = BinaryReader::new(&data);
let number = reader.read_u32().unwrap();
let text = reader.read_string().unwrap();
let pi = reader.read_f64().unwrap();
println!("Number: {}", number);
println!("Text: {}", text);
println!("Pi: {}", pi);
}
Bin-It supports writing and reading of: