pub struct BufferingTreeBuilder { /* private fields */ }
Expand description
UnixFs directory tree builder which buffers entries until build()
is called.
Implementations
sourceimpl BufferingTreeBuilder
impl BufferingTreeBuilder
sourcepub fn new(opts: TreeOptions) -> Self
pub fn new(opts: TreeOptions) -> Self
Construct a new tree builder with the given configuration.
sourcepub fn put_link(
&mut self,
full_path: &str,
target: Cid,
total_size: u64
) -> Result<(), TreeBuildingFailed>
pub fn put_link(
&mut self,
full_path: &str,
target: Cid,
total_size: u64
) -> Result<(), TreeBuildingFailed>
Registers the given path to be a link to the cid that follows. The target leaf should be either a file, directory or symlink but could of course be anything. It will be treated as an opaque link.
sourcepub fn set_metadata(
&mut self,
full_path: &str,
metadata: Metadata
) -> Result<(), TreeBuildingFailed>
pub fn set_metadata(
&mut self,
full_path: &str,
metadata: Metadata
) -> Result<(), TreeBuildingFailed>
Directories get “put” implicitly through the put files, and directories need to be adjusted only when wanting them to have metadata.
sourcepub fn build(self) -> PostOrderIteratorⓘNotable traits for PostOrderIteratorimpl Iterator for PostOrderIterator type Item = Result<OwnedTreeNode, TreeConstructionFailed>;
pub fn build(self) -> PostOrderIteratorⓘNotable traits for PostOrderIteratorimpl Iterator for PostOrderIterator type Item = Result<OwnedTreeNode, TreeConstructionFailed>;
Called to build the tree. The built tree will have the added files and their implied
directory structure, along with the directory entries which were created using
set_metadata
. To build the whole hierarchy, one must iterate the returned iterator to
completion while storing the created blocks.
Returned PostOrderIterator
will use the given full_path
and block_buffer
to store
its data during the walk. PostOrderIterator
implements Iterator
while also allowing
borrowed access via next_borrowed
.