Struct rust_unixfs::walk::Walker
source · pub struct Walker { /* private fields */ }Expand description
Walker helps with walking a UnixFS tree, including all of the content and files. It is
created with Walker::new and walked over each block with Walker::continue_block. Use
Walker::pending_links to obtain the next [Cid] to be loaded and the prefetchable links.
Implementations§
source§impl Walker
impl Walker
sourcepub fn new(cid: Cid, root_name: String) -> Walker
pub fn new(cid: Cid, root_name: String) -> Walker
Returns a new instance of a walker, ready to start from the given Cid.
sourcepub fn pending_links(&self) -> (&Cid, impl Iterator<Item = &Cid> + '_)
pub fn pending_links(&self) -> (&Cid, impl Iterator<Item = &Cid> + '_)
Returns the next [Cid] to load and pass its associated content to [next].
Panics
When [should_continue()] returns false.
sourcepub fn next<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
bytes: &'b [u8],
cache: &mut Option<Cache>
) -> Result<ContinuedWalk<'c>, Error>
pub fn next<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
bytes: &'b [u8],
cache: &mut Option<Cache>
) -> Result<ContinuedWalk<'c>, Error>
Continues the walk.
Returns a descriptor for the next element found as ContinuedWalk which includes the means
to further continue the walk. bytes is the raw data of the next block, cache is an
optional cache for data structures which can always be substituted with &mut None.
sourcepub fn should_continue(&self) -> bool
pub fn should_continue(&self) -> bool
Returns true if there are more links to walk over.