Skip to content

Commit

Permalink
Make chunk_grid::{regular,rectangular} public
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Apr 29, 2024
1 parent d475b01 commit 810ffc6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Allow float fill values to be created from int fill value metadata
- Make `chunk_grid::{regular,rectangular}` public

### Fixed
- Fix `compute_encoded_size()` for `BitroundCodec` incorrectly indicating various data types were unsupported
Expand Down
4 changes: 2 additions & 2 deletions src/array/chunk_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//!
//! A regular chunk grid can be created [from a `Vec<usize>` chunk shape](./type.ChunkGrid.html#method.from).
mod rectangular;
mod regular;
pub mod rectangular;
pub mod regular;

use std::num::NonZeroU64;

Expand Down
9 changes: 8 additions & 1 deletion src/array/chunk_grid/rectangular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ fn is_name_rectangular(name: &str) -> bool {
name.eq(IDENTIFIER)
}

pub fn create_chunk_grid_rectangular(metadata: &Metadata) -> Result<ChunkGrid, PluginCreateError> {
/// Create a rectangular chunk grid from metadata.
///
/// # Errors
/// Returns a [`PluginCreateError`] if the metadata is invalid for a regular chunk grid.
fn create_chunk_grid_rectangular(metadata: &Metadata) -> Result<ChunkGrid, PluginCreateError> {
let configuration: RectangularChunkGridConfiguration = metadata
.to_configuration()
.map_err(|_| PluginMetadataInvalidError::new(IDENTIFIER, "chunk grid", metadata.clone()))?;
Expand All @@ -45,10 +49,13 @@ pub struct RectangularChunkGridConfiguration {
pub chunk_shape: Vec<RectangularChunkGridDimensionConfiguration>,
}

/// A chunk element in the `chunk_shape` field of `rectangular` chunk grid netadata.
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Debug, From)]
#[serde(untagged)]
pub enum RectangularChunkGridDimensionConfiguration {
/// A fixed chunk size.
Fixed(NonZeroU64),
/// A varying chunk size.
Varying(ChunkShape),
}

Expand Down
4 changes: 4 additions & 0 deletions src/array/chunk_grid/regular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ fn is_name_regular(name: &str) -> bool {
name.eq(IDENTIFIER)
}

/// Create a regular chunk grid from metadata.
///
/// # Errors
/// Returns a [`PluginCreateError`] if the metadata is invalid for a regular chunk grid.
pub fn create_chunk_grid_regular(metadata: &Metadata) -> Result<ChunkGrid, PluginCreateError> {
let configuration: RegularChunkGridConfiguration = metadata
.to_configuration()
Expand Down

0 comments on commit 810ffc6

Please sign in to comment.