| 287 | } |
| 288 | |
| 289 | fn reserve(&self, additional: usize) -> Result<(), OperationCodecError> { |
| 290 | let total = self |
| 291 | .bytes |
| 292 | .len() |
| 293 | .checked_add(additional) |
| 294 | .ok_or_else(|| OperationCodecError::new("canonical object length overflow"))?; |
| 295 | if total > MAX_OPERATION_OBJECT_BYTES { |
| 296 | return Err(OperationCodecError::new(format!( |
| 297 | "canonical operation object exceeds {MAX_OPERATION_OBJECT_BYTES} bytes" |
| 298 | ))); |
| 299 | } |
| 300 | Ok(()) |
| 301 | } |
| 302 | |
| 303 | fn put_bytes(&mut self, bytes: &[u8]) -> Result<(), OperationCodecError> { |
| 304 | self.reserve(bytes.len())?; |