#game-assets #archive #assets #game #filesystem #resources

vach

A simple archiving format, designed for storing assets in compact secure containers

21 releases

new 0.7.1 Feb 13, 2025
0.6.2 Jul 29, 2024
0.5.5 Jan 6, 2024
0.5.0 Sep 26, 2023
0.2.3 Nov 23, 2021

#63 in Compression

Download history 9/week @ 2024-11-28 17/week @ 2024-12-05 33/week @ 2024-12-12 4/week @ 2024-12-26 4/week @ 2025-01-02 89/week @ 2025-01-09 6/week @ 2025-01-23 18/week @ 2025-01-30 169/week @ 2025-02-06

193 downloads per month
Used in 3 crates (2 directly)

MIT license

69KB
1.5K SLoC

vach

A simple archiving format, written in Pure Rust.

Crate Version on Crates.io docs.rs
GitHub GitHub Build and Test actions GitHub issues

Docs | Repo

vach, pronounced like "duck" but with a "v", is an archiving and resource transmission format. It was built to be secure, contained and protected. vach also has in-built support for multiple compression schemes (LZ4, Snappy and Brolti), cryptographic hashing, custom flags per entry and encryption. Check out the vach spec at spec.txt. Any and all help will is much appreciated.


👄 Terminologies

  • Archive Source: Any source of data. That implements io::Seek and io::Read, for example a file (fs::File) or in memory buffer (io::Cursor<Vec<u8>>).
  • Leaf: Any actual data endpoint within an archive, for example footstep1.wav in sounds.vach.
  • Entry: Some data in the registry section of a vach source on an corresponding leaf. For example, { id: footstep.wav, location: 45, offset: 2345, flags: 0b0000_0000_0000_0000u16 }.

🀄 Show me some code dang it!

let mut target = Cursor::new(vec![]);

// Data to be written
let data_1 = b"Around The World, Fatter better stronker" as &[u8];
let data_2 = b"Imagine if this made sense" as &[u8];
let data_3 = b"Fast-Acting Long-Lasting, *Bathroom Reader*" as &[u8];

// Builder definition
let config = BuilderConfig::default();

// Add data
let mut leaves = [
  Leaf::new(data_1, "d1").compress(CompressMode::Always),
  Leaf::new(data_2, "d2").compress(CompressMode::Never),
  Leaf::new(data_3, "d3").compress(CompressMode::Detect) // picks the smaller of the compressed and uncompressed
];

// write archive
dump(&mut target, &mut leaves, &config, None)?;

// Load data
let archive = Archive::new(target)?;

// Quick assertions
assert_eq!(archive.fetch("d1")?.data.as_slice(), data_1);
assert_eq!(archive.fetch("d2")?.data.as_slice(), data_2);
assert_eq!(archive.fetch("d3")?.data.as_slice(), data_3);

For more information on how to use the library, read the documentation. Always read the documentation! or read the tests, they offer great insight into how the crate works.


🛠 Yet to be implemented

  • An CLI: CLI Crate
  • Data encryption.
  • Benchmarks.
  • Features to turn off (or to turn on) either the builder or the loader modules.
  • Some(examples) instead of None
  • Skynet, (coming very soon).
  • Some proper benchmarking code. (Call for participation)

If you appreciate the works of this repo, consider dropping a star. It will be much appreciated; 🌟

Dependencies

~0.3–3MB
~100K SLoC