| 15 | use crate::types::domain::DomainBound; |
| 16 | |
| 17 | pub fn check(array: &str, dims: &[DimSpec]) -> ArrayResult<()> { |
| 18 | if dims.is_empty() { |
| 19 | return Err(ArrayError::InvalidSchema { |
| 20 | array: array.to_string(), |
| 21 | detail: "at least one dimension is required".to_string(), |
| 22 | }); |
| 23 | } |
| 24 | let mut seen = HashSet::with_capacity(dims.len()); |
| 25 | for d in dims { |
| 26 | if !seen.insert(d.name.as_str()) { |
| 27 | return Err(ArrayError::InvalidDim { |
| 28 | array: array.to_string(), |
| 29 | dim: d.name.clone(), |
| 30 | detail: "duplicate dimension name".to_string(), |
| 31 | }); |
| 32 | } |
| 33 | check_bounds_match_type(array, d)?; |
| 34 | check_bound_order(array, d)?; |
| 35 | } |
| 36 | Ok(()) |
| 37 | } |
| 38 | |
| 39 | fn check_bounds_match_type(array: &str, d: &DimSpec) -> ArrayResult<()> { |
| 40 | let ok = matches!( |