pub struct Builder { /* private fields */ }Expand description
Builds a TFS image.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new(total_blocks: usize) -> Builder
pub fn new(total_blocks: usize) -> Builder
A freshly formatted image of total_blocks blocks.
The layout is derived rather than fixed: the allocation map is sized to cover the image at one tryte per block, and the inode table is sized to one inode per four blocks, which is generous for a small disk and costs little.
Sourcepub fn from_image(bytes: Vec<u8>) -> Builder
pub fn from_image(bytes: Vec<u8>) -> Builder
Reopens an existing image, reading its layout from the superblock.
For a host inspecting what a guest wrote. The layout fields are read back rather than recomputed, so an image built by something else is still readable as long as its superblock is honest.
Sourcepub fn inode_direct(&self, inode: i64, index: usize) -> i64
pub fn inode_direct(&self, inode: i64, index: usize) -> i64
A direct block pointer of an inode, for a host checking allocation.
Sourcepub fn inode_kind(&self, inode: i64) -> i64
pub fn inode_kind(&self, inode: i64) -> i64
The kind of an inode, for a host checking what a guest created.
Sourcepub fn data_start(&self) -> usize
pub fn data_start(&self) -> usize
First block available for data.
Sourcepub fn is_block_used(&self, block: usize) -> bool
pub fn is_block_used(&self, block: usize) -> bool
True if the allocation map marks block as in use.
Sourcepub fn mkdir(&mut self, path: &str) -> Result<i64, BuildError>
pub fn mkdir(&mut self, path: &str) -> Result<i64, BuildError>
Creates a directory at path, which must not already exist.
Parent directories must exist. path is absolute with or without a
leading slash.
Sourcepub fn write_file(&mut self, path: &str, data: &[u8]) -> Result<i64, BuildError>
pub fn write_file(&mut self, path: &str, data: &[u8]) -> Result<i64, BuildError>
Creates a file at path holding data, one byte per tryte.