pub struct TreeReader<S: Store> { /* private fields */ }Expand description
TreeReader - reads and traverses merkle trees
Implementations§
Source§impl<S: Store> TreeReader<S>
impl<S: Store> TreeReader<S>
pub fn new(store: Arc<S>) -> Self
Sourcepub async fn get_blob(
&self,
hash: &Hash,
) -> Result<Option<Vec<u8>>, ReaderError>
pub async fn get_blob( &self, hash: &Hash, ) -> Result<Option<Vec<u8>>, ReaderError>
Get raw data by hash
Sourcepub async fn get_tree_node(
&self,
hash: &Hash,
) -> Result<Option<TreeNode>, ReaderError>
pub async fn get_tree_node( &self, hash: &Hash, ) -> Result<Option<TreeNode>, ReaderError>
Get and decode a tree node
Sourcepub async fn is_tree(&self, hash: &Hash) -> Result<bool, ReaderError>
pub async fn is_tree(&self, hash: &Hash) -> Result<bool, ReaderError>
Check if hash points to a tree node or blob
Sourcepub async fn is_directory(&self, hash: &Hash) -> Result<bool, ReaderError>
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
Sourcepub async fn get(&self, cid: &Cid) -> Result<Option<Vec<u8>>, ReaderError>
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.
Sourcepub async fn read_file(
&self,
hash: &Hash,
) -> Result<Option<Vec<u8>>, ReaderError>
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
Sourcepub async fn read_file_range(
&self,
hash: &Hash,
start: u64,
end: Option<u64>,
) -> Result<Option<Vec<u8>>, ReaderError>
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.
Sourcepub async fn read_file_chunks(
&self,
hash: &Hash,
) -> Result<Vec<Vec<u8>>, ReaderError>
pub async fn read_file_chunks( &self, hash: &Hash, ) -> Result<Vec<Vec<u8>>, ReaderError>
Read a file with streaming (returns chunks as vec)
Sourcepub async fn list_directory(
&self,
hash: &Hash,
) -> Result<Vec<TreeEntry>, ReaderError>
pub async fn list_directory( &self, hash: &Hash, ) -> Result<Vec<TreeEntry>, ReaderError>
List directory entries
Sourcepub async fn resolve_path(
&self,
root_hash: &Hash,
path: &str,
) -> Result<Option<Hash>, ReaderError>
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”)