Crates.io | snowbinary |
lib.rs | snowbinary |
version | 0.4.0 |
source | src |
created_at | 2021-04-16 19:00:48.049924 |
updated_at | 2024-03-27 20:47:40.799424 |
description | A header based system for writing and reading binary files using its own format |
homepage | |
repository | https://github.com/harmless-tech/snowbinary |
max_upload_size | |
id | 385425 |
size | 26,001 |
A basic header based binary file format, writer and reader.
{
let info = SnowBinInfo::default();
let writer = SnowBinWriter::new(info, PATH as PathBuf)?;
writer.write("Header", DATA as &[u8])?;
} // File is flushed when writer.close() is called or when writer is dropped.
{
let reader = SnowBinReader::new()?;
reader.read("Header")?; // Returns data has Vec<u8>
}
Default Max Header Size: 8 bytes.
Default Max Data Size: u64.
Start with an 8 byte header of "SNOW_BIN".
Then 8 bytes showing the snow binary version. (Spec Version) (u64)
Then 4 bytes showing the max header size in bytes. (At least 8 bytes, max of u32::MAX bytes) (u32)
Then 1 byte showing the max data size. (u8::MAX, u16::MAX, u32::MAX, u64::MAX) (u8)
Then write data:
End with a MAX_HEADER_SIZE header of "SNOW_END".
32 byte verification hash. (Using blake3)