1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Zarr chunk grids.
//!
//! See <https://zarr-specs.readthedocs.io/en/latest/v3/core/index.html#chunk-grids>.
//!
//! A [`ChunkGrid`](zarrs_chunk_grid::ChunkGrid) is an [`Arc`](std::sync::Arc) wrapped [`ChunkGridTraits`](zarrs_chunk_grid::ChunkGridTraits) implementation.
//! Chunk grids are Zarr extension points and they can be registered through [`inventory`] as a [`ChunkGridPlugin`](zarrs_chunk_grid::ChunkGridPlugin).
//!
#![doc = include_str!("../../doc/status/chunk_grids.md")]
pub mod rectangular;
pub mod rectilinear;
pub mod regular;
pub mod regular_bounded;
pub use rectangular::*;
pub use rectilinear::*;
pub use regular::*;
pub use regular_bounded::*;
/// Re-export the `zarrs_chunk_grid` API.
///
/// The API is mostly useful to implementors of custom chunk grids.
/// Users can import less used types (e.g. errors) from this crate if needed.
pub use zarrs_chunk_grid as api;
#[cfg(test)]
mod tests {
use zarrs_chunk_grid::ChunkGrid;
use zarrs_metadata::v3::MetadataV3;
#[test]
fn chunk_grid_configuration_regular() {
let json = r#"
{
"name": "regular",
"configuration": {
"chunk_shape": [5, 20, 400]
}
}"#;
let metadata = serde_json::from_str::<MetadataV3>(json).unwrap();
ChunkGrid::from_metadata(&metadata, &[400, 400, 400]).unwrap();
}
#[test]
fn chunk_grid_configuration_rectangular() {
let json = r#"
{
"name": "rectangular",
"configuration": {
"chunk_shape": [[5, 5, 5, 15, 15, 20, 35], 10]
}
}"#;
let metadata = serde_json::from_str::<MetadataV3>(json).unwrap();
ChunkGrid::from_metadata(&metadata, &[100, 100]).unwrap();
}
}