Validate that `attrs` presence matches the operation kind. Returns [`ArrayError::InvalidOp`] if the shape contract is violated.
(&self)
| 97 | /// |
| 98 | /// Returns [`ArrayError::InvalidOp`] if the shape contract is violated. |
| 99 | pub fn validate_shape(&self) -> ArrayResult<()> { |
| 100 | match self.kind { |
| 101 | ArrayOpKind::Put => { |
| 102 | if self.attrs.is_none() { |
| 103 | return Err(ArrayError::InvalidOp { |
| 104 | detail: "Put op must carry attrs".into(), |
| 105 | }); |
| 106 | } |
| 107 | } |
| 108 | ArrayOpKind::Delete | ArrayOpKind::Erase => { |
| 109 | if self.attrs.is_some() { |
| 110 | return Err(ArrayError::InvalidOp { |
| 111 | detail: format!("{:?} op must not carry attrs", self.kind), |
| 112 | }); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | Ok(()) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | #[cfg(test)] |