Skip to main content

TreeReader

Struct TreeReader 

Source
pub struct TreeReader<S: Store> { /* private fields */ }
๐Ÿ‘ŽDeprecated since 0.3.1:

use HashTree, which covers the same operations

Expand description

TreeReader - reads and traverses merkle trees

Implementationsยง

Sourceยง

impl<S: Store> TreeReader<S>

Source

pub fn new(store: Arc<S>) -> Self

Source

pub async fn get_blob( &self, hash: &Hash, ) -> Result<Option<Vec<u8>>, ReaderError>

Get raw data by hash

Source

pub async fn get_tree_node( &self, hash: &Hash, ) -> Result<Option<TreeNode>, ReaderError>

Get and decode a tree node

Source

pub async fn is_tree(&self, hash: &Hash) -> Result<bool, ReaderError>

Check if hash points to a tree node or blob

Source

pub async fn is_directory(&self, hash: &Hash) -> Result<bool, ReaderError>

Check if hash points to a directory (tree with named links) vs a chunked file (tree with unnamed links) or raw blob

Source

pub async fn get(&self, cid: &Cid) -> Result<Option<Vec<u8>>, ReaderError>

Read content by CID (handles both encrypted and public content)

This is the unified read method that handles decryption automatically when the CID contains an encryption key.

Source

pub async fn read_file( &self, hash: &Hash, ) -> Result<Option<Vec<u8>>, ReaderError>

Read a complete file (reassemble chunks if needed) For unencrypted content only - use get() for unified access

Source

pub async fn read_file_range( &self, hash: &Hash, start: u64, end: Option<u64>, ) -> Result<Option<Vec<u8>>, ReaderError>

Read a byte range from a file (fetches only necessary chunks)

  • start: Starting byte offset (inclusive)
  • end: Ending byte offset (exclusive), or None to read to end

For unencrypted content only - encrypted range reads not yet supported.

Source

pub async fn read_file_chunks( &self, hash: &Hash, ) -> Result<Vec<Vec<u8>>, ReaderError>

Read a file with streaming (returns chunks as vec)

Source

pub async fn list_directory( &self, hash: &Hash, ) -> Result<Vec<TreeEntry>, ReaderError>

List directory entries

Source

pub async fn resolve_path( &self, root_hash: &Hash, path: &str, ) -> Result<Option<Hash>, ReaderError>

Resolve a path within a tree e.g., resolve_path(โ€œroot/foo/bar.txtโ€)

Source

pub async fn get_size(&self, hash: &Hash) -> Result<u64, ReaderError>

Get total size of a tree

Source

pub async fn walk( &self, hash: &Hash, path: &str, ) -> Result<Vec<WalkEntry>, ReaderError>

Walk entire tree depth-first

Auto Trait Implementationsยง

ยง

impl<S> Forget for TreeReader<S>

ยง

impl<S> Freeze for TreeReader<S>
where Arc<S>: Freeze,

ยง

impl<S> RefUnwindSafe for TreeReader<S>
where Arc<S>: RefUnwindSafe,

ยง

impl<S> Send for TreeReader<S>
where Arc<S>: Send,

ยง

impl<S> Sync for TreeReader<S>
where Arc<S>: Sync,

ยง

impl<S> Unpin for TreeReader<S>
where Arc<S>: Unpin,

ยง

impl<S> UnsafeUnpin for TreeReader<S>
where Arc<S>: UnsafeUnpin,

ยง

impl<S> UnwindSafe for TreeReader<S>
where Arc<S>: UnwindSafe,

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = !

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

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

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V