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: StringThe ID under which the embedded data will be referenced
content_version: u8The version of the content, allowing you to track obsolete data.
compress: CompressModeHow a Leaf should be compressed
flags: FlagsThe flags that will go into the archive write target.
encrypt: boolUse encryption when writing into the target.
sign: boolWhether 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);