Skip to content
/ zarr Public

Rust implementation of the Zarr N-dimensional array format.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

sci-rs/zarr

Repository files navigation

Zarr Build Status Coverage

A pure rust implementation of version 3.0-dev of the Zarr core protocol for storage and retrieval of N-dimensional typed arrays.

Minimum supported Rust version (MSRV)

Stable 1.41

Quick start

[dependencies]
zarr = "0.0.1"
use zarr::prelude::*;
use zarr::smallvec::smallvec;

fn zarr_roundtrip(root_path: &str) -> std::io::Result<()> {
    let n = FilesystemHierarchy::open_or_create(root_path)?;

    let chunk_shape = smallvec![44, 33, 22];
    let array_meta = ArrayMetadata::new(
        smallvec![100, 200, 300],
        chunk_shape,
        i16::ZARR_TYPE,
        CompressionType::default(),
    );
    let chunk_data = vec![0i16; array_meta.get_chunk_num_elements()];

    let chunk_in = SliceDataChunk::new(
        smallvec![0, 0, 0],
        &chunk_data);

    let path_name = "/test/array/group";

    n.create_array(path_name, &array_meta)?;
    n.write_chunk(path_name, &array_meta, &chunk_in)?;

    let chunk_out = n.read_chunk::<i16>(path_name, &array_meta, smallvec![0, 0, 0])?
        .expect("Chunk is empty");
    assert_eq!(chunk_out.get_data(), &chunk_data[..]);

    Ok(())
}

fn main() {
    zarr_roundtrip("tmp.zr3").expect("Zarr roundtrip failed!");
    std::fs::remove_dir_all("tmp.zr3").expect("Failed to delete temporary zarr hierarchy");
}

Status

TODO

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Rust implementation of the Zarr N-dimensional array format.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages