Skip to content
forked from zeskeertwee/vach

A simple archiving format, in Pure Rust. Has a C API, CLI, compression, signing and encryption

License

Notifications You must be signed in to change notification settings

sokorototo/vach

 
 

Repository files navigation

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

About

A simple archiving format, in Pure Rust. Has a C API, CLI, compression, signing and encryption

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 91.9%
  • C 4.9%
  • JavaScript 2.4%
  • Shell 0.8%