Struct vach::builder::Builder [−][src]
pub struct Builder<'a> { /* fields omitted */ }Expand description
The archive builder. Provides an interface with which one can configure and build out valid vach archives.
Implementations
Appends a read handle wrapped in a Leaf into the processing queue.
The data is wrapped in the default Leaf.
The second argument is the ID with which the embedded data will be tagged
Errors
Returns an Err(()) if a Leaf with the specified ID exists.
Loads all files from a directory, parses them into Leafs and appends them into the processing queue.
An optional Leaf is passed as a template from which the new Leafs shall implement, pass None to use the Builder internal default template.
Appended Leafs have an ID in the form of of: directory_name/file_name. For example: “sounds/footstep.wav”, “sample/script.data”
Errors
- Any of the underlying calls to the filesystem fail.
- The internal call to
Builder::add_leaf()returns an error.
Append a preconstructed Leaf into the processing queue.
Leafs added directly do not implement data from the Builders internal template.
Errors
- Returns an error if a
Leafwith the specifiedIDexists.
Avoid unnecessary boilerplate by auto-templating all Leafs added with Builder::add(--) with the given template
use vach::builder::{Builder, Leaf, CompressMode};
let template = Leaf::default().compress(CompressMode::Always).version(12);
let mut builder = Builder::new().template(template);
builder.add(b"JEB" as &[u8], "JEB").unwrap();
// `JEB` is compressed and has a version of 12pub fn dump<W: Write + Seek>(
&mut self,
target: W,
config: &BuilderConfig
) -> InternalResult<usize>
pub fn dump<W: Write + Seek>(
&mut self,
target: W,
config: &BuilderConfig
) -> InternalResult<usize>
This iterates over all Leafs in the processing queue, parses them and writes the bytes out into a the target.
Configure the custom MAGIC, Header flags and a Keypair using the BuilderConfig struct.
Errors
- Underlying
ioerrors - If the optional compression or compression stages fails
- If the requirements of a given stage, compression or encryption, are not met. Like not providing a keypair if a
Leafis to be encrypted.