Expand description
A simple archive format, in Pure Rust.
Β§π« Cargo Features
archive: Enables the Archive loader.builder: Enables the Archive builder.multithreaded:dumpprocesses leaves in parallel, number of threads can be set manually usingnum_threads.compression: Pullssnap,lz4_flexandbrotlias dependencies and enables compression.crypto: Enables encryption and authentication by pulling theed25519_dalekandaes_gcmcratesdefault: Enables thearchiveandbuilderfeatures.all: Enables all the above features.
Β§π Show me some code dang it!
use std::{io::Cursor, fs::File};
use vach::prelude::*;
// collect leaves in a vector, or static buffer
let mut leaves = [
// Leaf::new(File::open("background.wav").unwrap(), "ambient"),
Leaf::new([12, 23, 34, 45, 56, 67, 78, 90, 69].as_slice(), "ftstep").compress(CompressMode::Always),
Leaf::new(b"Hello, Cassandra!".as_slice(), "hello")
];
// let mut target = File::create("sounds.vach")?;
let mut target = Cursor::new(Vec::new());
let config = BuilderConfig::default();
let bytes_written = dump(&mut target, &mut leaves, &config, None).unwrap();
// roundtrip
let mut archive = Archive::new(target).unwrap();
let resource = archive.fetch_mut("ftstep").unwrap();
assert_eq!(resource.data.as_ref(), [12, 23, 34, 45, 56, 67, 78, 90, 69].as_slice());ModulesΒ§
- archive
archive - Archive Reading logic and data-structures,
Archive,Resource - builder
builder - Archive Creation logic and data structures,
dump,LeafandBuilderConfig - crypto
crypto - Import keypairs and signatures from here, mirrors from
ed25519_dalek - crypto_
utils crypto - Some utility functions to keep you happy
- prelude
- Consolidated crate imports.
ConstantsΒ§
- MAGIC
- Magic Sequence used by
vach: βVfACHβ - MAX_
ID_ LENGTH - Maximum size for any ID, ie u16::MAX
- PUBLIC_
KEY_ LENGTH - Size of a public key
- SECRET_
KEY_ LENGTH - Size of a secret key
- SIGNATURE_
LENGTH - Size of a signature
- VERSION
- Current
vachspec version. increments by ten with every spec change