Expand description
Rust bindings for blosc2 - a fast, compressed, persistent binary data store library.
Provide a safe interface to the blosc2 library, which is a new major version of the original blosc library.
The library provides Ndarray, an n-dimensional array implementation with compressed
storage, and some lower level utilities for working with compressed data such as Chunk
and SChunk.
§Getting Started
To use this library, add the following to your Cargo.toml:
[dependencies]
blosc2 = "0.2"The Ndarray is an n-dimensional array with compressed storage, that support random access
to items or slices.
In the following example, we create a new Ndarray from an array from the ndarray crate, and than access its
elements and slice:
use blosc2::nd::{Ndarray, NdarrayParams};
let arr = Ndarray::from_ndarray(
&ndarray::array!([1_i32, 2, 3], [4, 5, 6], [7, 8, 9]),
NdarrayParams::default()
.chunkshape(Some(&[2, 2]))
.blockshape(Some(&[1, 1])),
).unwrap();
assert_eq!(4, arr.get::<i32>(&[1, 0]).unwrap());
assert_eq!(9, arr.get::<i32>(&[2, 2]).unwrap());
let slice_arr: ndarray::Array2<i32> = arr.slice(&[0..2, 1..3]).unwrap();
assert_eq!(slice_arr, ndarray::array![[2, 3], [5, 6]]);The library provides a high level Ndarray struct, which is built upon the
SChunk, that in itself is built upon Chunk.
Most users will probably interact only with the Ndarray, but the chunks types are also available.
§Features
zlib: Enable support for the zlib compression codec.zstd: Enable support for the zstd compression codec.ndarray: Enable conversions between blosc2’sNdarrayand thendarraycrate’sArrayBasetypes.half: Add a dependency to thehalfcrate, and implement theDtypedtrait forhalf::f16. See theutilmodule for the info.num-complex: Add a dependency to thenum-complexcrate, and implement theDtypedtrait fornum_complex::Complex<f32>andnum_complex::Complex<f64>. See theutilmodule for the info.
§Error Handling
The library follow the C API and returns error codes. In addition, if the environment variable
BLOSC_TRACE is set, it will print detailed trace during failures which is useful for
debugging.
Re-exports§
pub use ndarray;ndarray
Modules§
- chunk
- Basic
ChunkandSChunktypes. - nd
- n-dimensional arrays with compressed storage (blosc2 NDarray, b2nd).
- util
- Utility functions and types.
Structs§
- CParams
- Compression parameters, used by
Encoder,SChunkandNdarray. - DParams
- Decompression parameters, used by
Decoder,SChunkandNdarray.
Enums§
- Compress
Algo - Compression algorithms supported by blosc2.
- Error
- Error codes for the blosc2 library.
- Filter
- Filters that can be applied to the data before compression.
- Split
Mode - A split mode option for encoders.
Constants§
- BLOS
C2_ C_ VERSION - The version of the underlying C-blosc2 library used by this crate.
- VERSION
- The version of the crate.
Functions§
- compressor_
lib_ info - Get info from a compression library included in the current build.
- list_
compressors - Get a list of compressors names supported in the current build.