TreeReader

Struct TreeReader 

Source
pub struct TreeReader<S: Store> { /* private fields */ }
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> Freeze for TreeReader<S>

§

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

§

impl<S> Send for TreeReader<S>

§

impl<S> Sync for TreeReader<S>

§

impl<S> Unpin for TreeReader<S>

§

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

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<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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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