(&mut self, value: &str, field: &str)
| 334 | } |
| 335 | |
| 336 | fn put_string(&mut self, value: &str, field: &str) -> Result<(), OperationCodecError> { |
| 337 | if value.is_empty() { |
| 338 | return Err(OperationCodecError::new(format!("{field} cannot be empty"))); |
| 339 | } |
| 340 | if value.len() > MAX_OPERATION_STRING_BYTES { |
| 341 | return Err(OperationCodecError::new(format!( |
| 342 | "{field} exceeds {MAX_OPERATION_STRING_BYTES} UTF-8 bytes" |
| 343 | ))); |
| 344 | } |
| 345 | let len = u32::try_from(value.len()) |
| 346 | .map_err(|_| OperationCodecError::new(format!("{field} length exceeds u32")))?; |
| 347 | self.put_u32(len)?; |
| 348 | self.put_bytes(value.as_bytes()) |
| 349 | } |
| 350 | |
| 351 | fn put_blob(&mut self, value: &[u8], field: &str) -> Result<(), OperationCodecError> { |
| 352 | if value.len() > MAX_OPERATION_OBJECT_BYTES { |
no test coverage detected