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

Instantiates a new Builder with an empty processing queue.

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 Leaf with the specified ID exists.

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 12

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 io errors
  • 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 Leaf is to be encrypted.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.