pub struct BlockDir {
pub path: PathBuf,
}
Expand description
A readable, writable directory within a band holding data blocks.
Fields§
§path: PathBuf
Implementations§
source§impl BlockDir
impl BlockDir
sourcepub fn new(path: &Path) -> BlockDir
pub fn new(path: &Path) -> BlockDir
Create a BlockDir accessing path
, which must exist as a directory.
sourcepub fn create(path: &Path) -> Result<BlockDir>
pub fn create(path: &Path) -> Result<BlockDir>
Create a BlockDir directory and return an object accessing it.
sourcepub fn store(
&mut self,
from_file: &mut dyn Read,
report: &Report
) -> Result<(Vec<Address>, String)>
pub fn store(
&mut self,
from_file: &mut dyn Read,
report: &Report
) -> Result<(Vec<Address>, String)>
Store the contents of a readable file into the BlockDir.
Returns the addresses at which it was stored, plus the hash of the overall original file.
sourcepub fn contains(&self, hash: &str) -> Result<bool>
pub fn contains(&self, hash: &str) -> Result<bool>
True if the named block is present in this directory.
sourcepub fn get_block(&self, hash: &str) -> Block
pub fn get_block(&self, hash: &str) -> Block
Get an object accessing a whole block. The contents are not yet narrowed down to only the addressed region.
sourcepub fn get(&self, addr: &Address, report: &Report) -> Result<Vec<u8>>
pub fn get(&self, addr: &Address, report: &Report) -> Result<Vec<u8>>
Read back the contents of a block, as a byte array.
To read a whole file, use StoredFile instead.
sourcepub fn block_names(&self, report: &Report) -> Result<Vec<String>>
pub fn block_names(&self, report: &Report) -> Result<Vec<String>>
Return a sorted vec of all the blocknames in the blockdir.