scirs2-io
Scientific data input/output for the SciRS2 scientific computing library (v0.6.2).
scirs2-io provides comprehensive, high-performance file I/O for scientific and numerical workloads. It covers everything from classic scientific formats (MATLAB, NetCDF, HDF5, WAV, NumPy, Fortran unformatted, IDL) through domain-specific formats (FITS/VOTable, FASTA/FASTQ/SAM/BAM/VCF, GeoTIFF/Shapefile/GeoJSON/KML), modern columnar and lakehouse formats (Parquet, Arrow IPC, Zarr, Delta Lake, Iceberg), to cloud storage, ETL pipelines, data catalogs, and lineage tracking — all as pure Rust with no required C/Fortran dependencies.
Features (v0.6.2)
Classic Scientific Formats
- MATLAB (.mat):
.matv4/v5 read/write with structures and cell arrays, plus v7.3 (HDF5-based) read/write —EnhancedMatFile,V73MatFile,PartialIoSupport— now available in default builds via the pure-Rustoxih5backend; nohdf5Cargo feature or systemlibhdf5required - WAV: Professional-grade WAV audio read/write
- ARFF: Complete Weka Attribute-Relation File Format support
- NetCDF: Hand-rolled, pure-Rust NetCDF3 Classic and NetCDF4/HDF5 reader/writer with unlimited dimensions and chunking (
netcdf/, 1300+ lines; does not wrap the externalnetcdf3crate — that dependency is currently unused dead weight inCargo.toml) - HDF5: Pure-Rust hierarchical data format read/write via
oxih5— nolibhdf5, no C toolchain, and no feature flag to enable. Covers superblocks v0–v3, version-1 and version-2 B-trees, fractal heaps, symbol-table and link-message groups, contiguous/chunked/compact layouts, extensible and fixed array chunk indices, virtual datasets, hyperslab selections, deflate and szip decompression, memory-mapped reads, and attributes on groups and datasets - NumPy (.npy/.npz): NumPy binary array format and ZIP-of-arrays archives
- Fortran unformatted files: Read/write support for Fortran sequential unformatted records, common in physics/weather/engineering codes
- IDL save files (.sav): Reader/writer for Interactive Data Language save files used in astronomy and remote sensing
- Matrix Market / Harwell-Boeing: Sparse and dense matrix exchange formats
- Sparse matrix formats: Unified COO/CSR/CSC support with conversions between representations
Domain-Specific Scientific Formats
- Astronomical: FITS (Flexible Image Transport System) image/table read-write, VOTable (Virtual Observatory Table) column access
- Bioinformatics: FASTA and FASTQ sequence read/write (with quality scores), SAM/BAM alignment format, VCF variant call format
- Geospatial: GeoTIFF (georeferenced raster bands/windows), Shapefile, GeoJSON, KML/KMZ read/write
Modern Columnar, Lakehouse, and Binary Formats
- Parquet (
parquetfeature): real Apache Arrow/Parquet-ecosystem reader/writer (via thearrowandparquetcrates) with schema inference, predicate pushdown, row-group statistics, and Pandas/Polars/PyArrow interoperability - Parquet-lite: always-available, pure-Rust simplified columnar format that borrows Parquet's structural ideas (magic bytes, row groups, footer) without the
parquet/arrowdependency — not binary-compatible with third-party.parquetfiles - Feather (Arrow IPC): Memory-mapped Arrow columnar format, zero-copy read/write
- ORC-style columnar formats: two self-contained pure-Rust formats (
formats::orc,formats::orc_lite) supporting RLE v2 integer encoding (direct/delta/variable-length), dictionary string encoding, and bit-packed boolean RLE — inspired by Apache ORC's on-disk design but using their own magic bytes/framing, not byte-compatible with third-party.orcfiles - Zarr v2/v3: Chunked, compressed, N-dimensional array store compatible with Zarr-Python
- TileDB-inspired arrays: Pure-Rust dense/sparse multidimensional array storage with tile-based I/O (row-major/column-major/Hilbert ordering), not a TileDB file-format client
- Lance-inspired columnar format: Pure-Rust, in-process reader/writer for a Lance-like ML-dataset columnar layout
- Delta Lake: JSON transaction-log (
_delta_log/) reader/writer with append commits, version conflict detection, checkpoint/replay, and time travel - Apache Iceberg (simplified): in-memory table abstraction with schema, snapshot-based versioning, and JSON metadata serialization
- Binary format utilities: Portable typed-array and columnar binary encoding helpers
Serialization Formats
- CBOR: Concise Binary Object Representation (RFC 7049), own
CborValuedata model with incremental encoder/decoder plusencode_cbor/decode_cborconvenience functions (not aserde-genericencode(&T)API) - BSON: Binary JSON as used by MongoDB ecosystems (all floating point stored as BSON
Double;f32values upcast tof64, matching the BSON type system) - Avro: Schema-based binary serialization with schema evolution support
- Protobuf: Two-tier pure-Rust implementation — low-level varint primitives (
protobuf_lite) plus a higher-levelProtoMessage/ProtoValueencoder/decoder (formats::protobuf); noprotoccode-generation dependency - MessagePack: Compact, fast binary serialization (via
rmp-serde) - JSON / NDJSON: Standard JSON and Newline-Delimited JSON (streaming-friendly)
Streaming and Lazy Evaluation
- Streaming CSV: Lazy, chunk-by-chunk CSV processing via
CsvStreamReader; handles files larger than RAM - Streaming JSON: Incremental JSON parser for large document streams
- NDJSON streaming: Line-by-line newline-delimited JSON processing
- Arrow IPC streaming: Framed streaming Arrow record batches; unexpected/unknown message tags now raise a
FormatErrorinstead of being silently skipped - Backpressure-aware pipelines: Push-pull pipeline with configurable buffer sizes
- Windowed aggregation: Tumbling, sliding, and session windows over event-time streams
- Watermarks: Watermark-based late-data handling for windowed operators
- Checkpointing: Periodic operator-state snapshots for restartable streaming jobs
- Exactly-once sinks: Write-ahead log (disk or in-memory) plus idempotency-key deduplication
Compression
- LZ4 / Zstd / Brotli / Snappy / GZIP / BZIP2: Pure-Rust codecs (via the
oxiarc-*family) — no zip/flate2/zstd/bzip2/lz4/miniz_oxide C dependencies - Parallel compression:
compress_data_parallel/decompress_data_parallel/compress_file_parallel/decompress_file_parallelin thecompressionmodule split input into chunks and compress them concurrently via Rayon (ParallelCompressionConfig,ParallelCompressionStats) - Adaptive compression: Runtime Shannon-entropy profiling auto-selects LZ4/Zstd/Brotli;
auto_compress/auto_decompressembed a 1-byte algorithm tag - GPU-assisted compression: backend detection/capability probing for CUDA, Metal, and OpenCL (
gpumodule); the OpenCL compression header now reports the adapter's real compute-unit count instead of a hardcoded placeholder
Data Catalog, Lineage, and Governance
- Data catalog: Register, tag, and discover datasets by name and schema
- Lineage tracking: Record transformations and data provenance for auditability
- Schema module:
Schema/SchemaField/SchemaBuilderdefinitions, validation, and type inference against data - Protobuf schema registry: separate, versioned
SchemaRegistrywith compatibility checks for Protobuf-shaped schemas (pure Rust, noprost) - Versioning support: Immutable dataset versioning with diff and rollback
- Metadata management: Unified metadata read/write across supported formats
- TOML configuration utilities: Typed config wrapper, deep-merge, flattening, and validation on top of the
tomlcrate
ETL, Query, and Analytics
- ETL pipeline framework: Declarative source → transform → sink pipelines with parallel stages
- Query interface: SQL-like predicate pushdown and projection for tabular formats
- DataFusion-compatible table provider: standalone abstraction mirroring the Apache DataFusion
TableProvidertrait without depending on thedatafusion/arrowcrates (two parallel implementations exist:table_provideranddatafusion_provider) - Vectorized expression evaluation: Row-at-a-time and SIMD-friendly filter/project evaluation over record batches
- Join algorithms: Hash join, sort-merge join, and nested-loop join across record batches
- Approximate analytics: Bloom filter column indexes, HyperLogLog++ cardinality estimation, t-digest quantiles, count-min sketch frequency estimation
- Columnar encodings: Dictionary encoding, run-length encoding, delta/zigzag/varint encoding, FSST string compression
- Universal reader: Automatic format detection from magic bytes and file extension
- Format detection: Detect dozens of formats without specifying them explicitly
Streaming Protocols and Messaging
- Real network clients (
realtimefeature, built on real crates): WebSocket (tokio-tungstenite), Server-Sent Events (eventsource-client), gRPC (tonic), and MQTT (rumqttc) client support - In-memory protocol simulations (for testing/offline development, no network involved): a Kafka-protocol in-memory broker (
protocols::kafka), an Arrow Flight in-memory simulation (protocols::arrow_flight), and an in-process MQTT-style topic broker with full wildcard matching (mqtt_broker)
Machine Learning / Tensor Interop
- SafeTensors: Read/write of the HuggingFace SafeTensors binary tensor format
- ONNX: Minimal hand-rolled protobuf parser/writer for ONNX
ModelProto(nodes, opsets, inputs/outputs) - TFRecord: Reader for TensorFlow's length-prefixed, CRC32C-checked record format
- Mini-batch sampling: Shuffled/stratified batch sampling with train/validation/test splitting
Database Connectivity
- SQLite: Real, pure-Rust implementation via
oxisql-sqlite-compat(Limbo engine) behind thesqlitefeature — query, execute, bulk array insert, schema introspection - PostgreSQL / MySQL: Feature flags exist (
postgres,mysql) but the connection types are explicit stubs that return "implementation pending" errors — nosqlxor other real driver is wired in yet - MongoDB / Redis: Feature flags exist for API-surface compatibility only; there is no backing crate or implementation
Cloud and Distributed I/O
- Object-store abstraction: A unified
ObjectStoretrait with fully workingLocalObjectStoreandMemoryObjectStorebackends - S3 / GCS / Azure backends: Configuration types, presigned-URL builders, and simulated multipart/resumable-upload state machines are real and tested; however
put/get/delete/list/headreturn a "real HTTP implementation not yet complete" error even when theaws-sdk-s3,google-cloud-storage, orazure-storage-blobsfeature is enabled — no live network call is made yet - Azure SAS tokens: Token structure and validation logic are real, but the signature is produced by a deterministic placeholder (
mock_sign), not HMAC-SHA256 — do not use for production Azure authentication - Distributed I/O: Partitioned parallel read/write for cluster workloads
Performance and Low-Level I/O
- Memory-mapped files:
mmap-based access for arrays larger than RAM - Zero-copy I/O: Allocation-minimizing read/write paths for large datasets
- SIMD-accelerated I/O: Vectorized encode/decode paths for supported hardware
- I/O thread pool: Configurable, work-stealing thread pool tuned for I/O-bound vs. CPU-bound tasks
- Out-of-core processing: Disk-backed algorithms for terabyte-scale datasets that don't fit in memory
- Experimental adaptive I/O tuning: heuristic runtime tuning modules named "neural-adaptive" and "quantum-inspired" (
neural_adaptive_io,quantum_inspired_io) implement real weight-update/Q-learning/parameter-search logic as optimization metaphors — they do not involve actual neural-network training frameworks or quantum hardware/simulators
Validation and Integrity
- Checksums: CRC32, SHA-256, BLAKE3 integrity verification
- Schema-based validation: JSON Schema-compatible validation engine
- Format validators: Format-specific structural validators
Quick Start
Add to your Cargo.toml:
[]
= "0.6.2"
To enable optional feature groups:
[]
= { = "0.6.2", = ["async", "parquet"] }
Reading a CSV file
use ;
let config = CsvReaderConfig ;
let = read_csv?;
println!;
println!;
Streaming a large NDJSON file
use NdjsonReader;
use File;
use BufReader;
let file = open?;
let mut reader = new;
while let Some = reader.next_record?
CBOR round-trip
use ;
let value = Map;
let bytes = encode_cbor;
let = decode_cbor?;
println!;
Streaming CSV in fixed-size chunks
use CsvStreamReader;
let mut reader = new?;
loop
Parallel Zstd compression
use ;
let data = read?;
let cfg = ParallelCompressionConfig ;
let = compress_data_parallel?;
println!;
API Overview
| Module | Purpose |
|---|---|
matlab |
.mat v4/v5/v7.3 (HDF5-based, via oxih5) file read/write |
wavfile |
WAV audio read/write |
netcdf |
NetCDF3/4 (hand-rolled, does not use the netcdf3 crate) |
hdf5 |
Pure-Rust HDF5 read/write via oxih5 (always available) |
npy |
NumPy .npy/.npz read/write |
fortran |
Fortran unformatted file read/write |
idl |
IDL .sav save file read/write |
csv |
CSV with type inference |
image |
PNG, JPEG, BMP, TIFF |
matrix_market / harwell_boeing |
Matrix Market / Harwell-Boeing |
sparse |
COO/CSR/CSC sparse matrix formats |
formats::astronomical |
FITS, VOTable |
formats::bioinformatics |
FASTA, FASTQ, SAM/BAM, VCF |
formats::geospatial |
GeoTIFF, Shapefile, GeoJSON, KML/KMZ |
formats::cbor |
CBOR encode/decode (CborValue model) |
formats::bson |
BSON encode/decode |
formats::avro |
Avro schema-based serialization |
formats::protobuf / protobuf_lite |
Protobuf message encoding / varint primitives |
msgpack / formats::msgpack |
MessagePack encode/decode |
formats::orc / formats::orc_lite |
ORC-inspired columnar formats |
formats::feather |
Feather (Arrow IPC) |
parquet |
Real Apache Arrow/Parquet reader/writer (feature-gated) |
parquet_lite |
Simplified Parquet-inspired reader (always available) |
zarr |
Zarr v2/v3 chunked arrays |
tiledb |
TileDB-inspired multidimensional arrays |
lance |
Lance-inspired ML columnar format |
delta |
Delta Lake transaction log reader/writer |
iceberg |
Simplified Apache Iceberg table abstraction |
streaming_csv |
Lazy streaming CSV (CsvStreamReader) |
streaming_json |
Streaming JSON parser |
ndjson_streaming |
NDJSON line-by-line streaming |
arrow_ipc / arrow_streaming |
Arrow IPC framed streaming |
streaming::windows / watermark / checkpoint |
Windowed aggregation, watermarks, checkpointing |
exactly_once |
Exactly-once delivery for streaming sinks |
binary_format / binary_formats |
Binary encoding utilities |
compression / compression_utils |
LZ4, Zstd, Brotli, Snappy, GZIP, BZIP2, parallel compression |
adaptive_compression |
Entropy-based automatic codec selection |
gpu |
GPU backend detection and GPU-assisted compression |
universal_reader |
Auto-detect format and open |
format_detect |
Magic bytes / extension detection |
query |
SQL-like predicate and projection |
joins |
Hash / sort-merge / nested-loop joins |
vectorized_eval |
Vectorized filter/project evaluation |
table_provider / datafusion_provider |
DataFusion-compatible table provider interface |
analytics |
Bloom filter, HyperLogLog++, t-digest, count-min sketch |
columnar |
Dictionary, RLE, delta/zigzag, FSST encoding |
catalog |
Data catalog |
lineage |
Provenance and lineage tracking |
schema |
Schema definitions, validation, and inference |
schema_registry |
Versioned Protobuf schema registry |
versioning |
Dataset versioning |
metadata |
Cross-format metadata management |
toml_ext |
Typed TOML configuration utilities |
etl |
ETL pipeline framework |
cloud / network |
Cloud storage connectors (S3/GCS/Azure — see Features) |
s3_multipart |
S3 multipart upload state machine |
distributed |
Distributed / partitioned I/O |
database |
SQLite (real), PostgreSQL/MySQL (stub) |
realtime |
Real WebSocket/SSE/gRPC/MQTT network clients |
protocols::kafka / protocols::arrow_flight |
In-memory protocol simulations |
mqtt_broker |
In-process MQTT-style pub/sub broker |
tensors |
SafeTensors, ONNX, TFRecord |
minibatch |
Mini-batch sampler |
pipeline |
Typed streaming pipeline (sources, transforms, sinks) |
validation |
Checksums, schema validation |
serialize |
Array and sparse-matrix serialization |
streaming |
Low-level streaming utilities |
mmap / zero_copy / simd_io / thread_pool / out_of_core |
Low-level performance I/O |
Feature Flags
| Feature | Description |
|---|---|
default |
csv, compression, validation, image_io |
csv |
CSV read/write support |
compression |
LZ4, Zstd, Brotli, Snappy pure-Rust codecs |
validation |
Checksums and schema validation |
image_io |
PNG/JPEG/BMP/TIFF via the image crate, plus EXIF metadata |
exif |
Alias enabling image_io for EXIF metadata access |
hdf5 |
No-op alias, retained so existing manifests keep resolving — HDF5 is unconditional (pure-Rust oxih5) |
parquet |
Real Apache Arrow/Parquet reader/writer (dep:parquet, dep:arrow) |
async |
Async I/O via tokio |
reqwest |
HTTP/HTTPS network I/O |
gpu |
GPU backend detection and GPU-assisted compression |
sqlite / sqlite-stable |
Pure-Rust SQLite via oxisql-sqlite-compat (real) |
postgres / mysql |
Stub connection types only — no real driver wired in |
mongodb / redis |
Placeholder feature names — no backing crate or implementation |
database |
sqlite + postgres + mysql |
database-full |
Alias for database |
aws-sdk-s3 / google-cloud-storage / azure-storage-blobs |
Gate cloud-vendor code paths, but live HTTP calls are not yet implemented (see Features) |
websocket |
Real WebSocket client via tokio-tungstenite (implies async) |
mqtt |
Real MQTT client via rumqttc (implies async) |
sse |
Real Server-Sent Events client via eventsource-client (implies async, reqwest) |
grpc |
Real gRPC client via tonic (implies async) |
realtime |
websocket + mqtt + sse + grpc |
all |
All of the above |
Testing
grep -rn "todo!()\|unimplemented!()" src/ returns 0 matches. Freshly measured 2026-07-15:
Both runs: 0 failed. See TODO.md for the feature-by-feature maturity caveats (several
feature-gated areas — postgres/mysql/mongodb/redis, live cloud HTTP, Azure SAS signing —
are explicit, off-by-default stubs, not silent gaps in the tested surface above).
Documentation
Full API documentation is available at docs.rs/scirs2-io.
License
Licensed under the Apache License 2.0. See LICENSE for details.