squashfs_reader

Crates.iosquashfs_reader
lib.rssquashfs_reader
version0.1.0
created_at2025-07-27 13:22:45.510889+00
updated_at2025-07-27 13:22:45.510889+00
descriptionFully featured rust reader for the squashfs archive format
homepage
repositoryhttps://github.com/Macdu/squashfs_reader
max_upload_size
id1770061
size121,745
Macdu (Macdu)

documentation

README

Squashfs_reader

Squashfs_reader is a rust crate offering full read-only access to squashfs archive files. It offers an api similar to std::io.

Features

  • Pure Rust: Implementation of the entire SquashFS format specification.
  • Full Compression Support: All possible compression formats (gzip, lzma, xz, lzo, lz4, and zstd) are supported.
  • Thread Safety: This library is fully thread-safe.
  • Caching: All accessed metadata and data blocks are cached using quick_cache to prevent unnecessary decompressions. The cache size can be configured.
  • Familiar API: Directory iteration is supported with an API similar to std::fs::ReadDir, and files implement the std::io::Read and std::io::Seek traits.

Example

use std::io;
use squashfs_reader::FileSystem;

fn main() -> io::Result<()> {
    // Open a SquashFS file
    let fs = FileSystem::from_path("example.squashfs")?;
    
    // List contents of root directory
    let root = fs.read_dir("/")?;
    for entry in root {
        println!("{}", entry?.name());
    }
    
    // Read a file
    let mut file = fs.open("path/to/file.txt")?;
    let file_size = file.seek(io::SeekFrom::End(0))?;
    file.rewind()?;

    let mut contents = String::new();
    file.read_to_string(&mut contents)?;
    
    Ok(())
}

Compression and features

  • best_performance (default) - Uses external (non-Rust) libraries when they offer better performance (liblzma and zstd-safe).
  • only_rust- Only has Rust dependencies, but may offer lower performance when using some compression formats.

If both features are enabled, only_rust will be prioritized.

Safety

This crate is entirely written in safe Rust (it uses #![forbid(unsafe_code)]). However, please note that some dependencies may contain unsafe code.

Commit count: 0

cargo fmt