#zstd #blosc

blusc

Rust implementation of blosc compression, port of c-blosc2

2 releases

new 0.0.2 Feb 10, 2026
0.0.1 Feb 6, 2026

#2 in #blosc

BSD-3-Clause

96KB
2K SLoC

blusc

This is a pure Rust implementation of c-blosc2 compression and decompression.

Blusc is not intended to be as performant as the reference C implementation, as the goal here is to enable easy compilation to WASM targets (so we avoid optimizations like multi-threading, hardware acceleration, etc). I have not performed any benchmarks.

Background

The Blosc algorithm wraps other compression methods, including zstd, snappy, lz4, and zlib. We will use pure Rust implementations of these inner compression methods:

This crate offers pure rust implementations of the following functions and constants:

  • blosc1_cbuffer_metainfo
  • blosc1_cbuffer_validate
  • blosc1_cbuffer_sizes
  • blosc1_getitem
  • blosc2_get_complib_info
  • blosc2_compress
  • blosc2_decompress
  • BLOSC_NOSHUFFLE
  • BLOSC2_MAX_OVERHEAD
  • BLOSC2_CPARAMS_DEFAULTS
  • BLOSC2_DPARAMS_DEFAULTS
  • blosc2_create_cctx
  • blosc2_compress_ctx
  • blosc2_cbuffer_sizes
  • blosc2_create_dctx
  • blosc2_decompress_ctx

Motivation

I tried and failed to compile existing Rust bindings to c-blosc to WASM (requiring shims for C standard library things), which motivated this pure Rust implementation. Another aspect that complicates things is that c-blosc internally uses C libraries such as zstd, which can result in function name conflicts when used in codebases that depend on both c-blosc and zstd bindings:

some_crate
  - rust-bindings-to-c-blosc
    - c-blosc (C implementation)
      - zstd (C implementation)
  - rust-bindings-to-zstd
    - zstd (C implementation)

More broadly, it makes sense to have alternative implementations (especially in Rust) of widely-used compression algorithms.

Development

cargo build

Testing

cargo test

For reference during development, this repository contains the C implementations in the c-blosc and c-blosc2 directories as git submodules.

AI usage disclaimer

This README, Cargo.toml, the public interface/function signatures, initial unit tests, and the contents of src/internal/constants.rs were written by me, a human, or manually ported. The rest of the Rust code and other unit tests were largely LLM-generated/ported (see AGENTS.md for more details).

Citing Blosc

Copied from the citing-blosc section of the c-blosc2 README.

@ONLINE{blosc,
    author = {{Blosc Development Team}},
    title = "{A fast, compressed and persistent data store library}",
    year = {2009-2025},
    note = {https://blosc.org}
}

Dependencies

~3.5MB
~63K SLoC