Struct vach::builder::Leaf[][src]

pub struct Leaf<'a> {
    pub id: String,
    pub content_version: u8,
    pub compress: CompressMode,
    pub flags: Flags,
    pub encrypt: bool,
    pub sign: bool,
    pub link_mode: Option<String>,
    // some fields omitted
}
Expand description

A wrapper around an io::Read handle. Allows for multiple types of data implementing io::Read to be used under one structure. Also used to configure how data will be processed and embedded into an write target.

Fields

id: String

The ID under which the embedded data will be referenced

content_version: u8

The version of the content, allowing you to track obsolete data.

compress: CompressMode

How a Leaf should be compressed

flags: Flags

The flags that will go into the archive write target.

encrypt: bool

Use encryption when writing into the target.

sign: bool

Whether to include a signature with this Leaf, defaults to false If set to true then a hash generated and validated when loaded

link_mode: Option<String>

If a Leaf has a link_mode of Some(“dw”), then this leaf simply routes the data pointed by the adjacent Leaf with the ID “dw”. Use this if you want to have multiple pointers|registry entries aliasing to the same data. The handle of a link leaf stores the ID of the aliased leaf.

Implementations

Wrap a Leaf around the given handle. Using the Default configuration.

 use vach::prelude::Leaf;
 use std::io::Cursor;

 let leaf = Leaf::from_handle(Cursor::new(vec![]));

Copy all fields from another Leaf, except for handle, link_mode and id Meant to be used like a setter:

use std::io::Cursor;
use vach::prelude::{Leaf, CompressMode};
let template = Leaf::default()
   .version(12)
   .compress(CompressMode::Always);

let leaf = Leaf::from_handle(Cursor::new(vec![])).template(&template);

Setter used to set the CompressMode of a Leaf

use vach::prelude::{Leaf, CompressMode};

let leaf = Leaf::default().compress(CompressMode::Always);

Setter used to set the content_version of a Leaf

use vach::prelude::{Leaf};

let leaf = Leaf::default().version(2);

Setter used to set the id field of a Leaf

use vach::prelude::{Leaf};

let leaf = Leaf::default().id("whatzitouya");

Setter used to set the Flags field of a Leaf

use vach::prelude::{Leaf, Flags};

let leaf = Leaf::default().flags(Flags::default());

Setter for the encrypt field

use vach::prelude::Leaf;
 let config = Leaf::default().encrypt(true);

Setter for the sign field

use vach::prelude::Leaf;
 let config = Leaf::default().sign(true);

Setter for the link_mode field

use vach::prelude::Leaf;
 let config = Leaf::default().link_mode(Some("default.tx".to_string()));

Trait Implementations

Formats the value using the given formatter. Read more

The default leaf holds no bytes at all, this is expected to be used as a stencil|template.

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.