[][src]Struct ipfs_unixfs::file::reader::FileReader

pub struct FileReader<'a> { /* fields omitted */ }

Navigates the UnixFs files, which are either:

  • single block files which have everything needed to all of the contents
  • multi block files which have trees of trees until Raw leaf blocks

The trees can have different shapes but it doesn't really matter for our depth-first approach. For seeking, the each sub-tree linking node will have blocksizes for the trees representing which the original file offsets covered by the tree.

A file doesn't know it's name. It only has a name when part of a directory, and then the name is on a PbLink::Name. With UnixFs the names are always UTF-8. The root CID is not interesting either: we just need the root block.

Implementations

impl<'a> FileReader<'a>[src]

pub fn from_block(data: &'a [u8]) -> Result<Self, FileReadFailed>[src]

Method for starting the file traversal. data is the raw data from unixfs block.

pub fn content(
    self
) -> (FileContent<'a, impl Iterator<Item = (PBLink<'a>, Range<u64>)>>, Traversal)
[src]

Returns a moved tuple of the content (bytes or links) and a traversal, which can be used to continue the traversal from the next block.

pub fn file_size(&self) -> u64[src]

Returns the total size of the file.

Trait Implementations

impl<'_> AsRef<Metadata> for FileReader<'_>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for FileReader<'a>

impl<'a> Send for FileReader<'a>

impl<'a> Sync for FileReader<'a>

impl<'a> Unpin for FileReader<'a>

impl<'a> UnwindSafe for FileReader<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.