MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / put_string

Method put_string

atomic-core/src/operation/codec.rs:336–349  ·  view source on GitHub ↗
(&mut self, value: &str, field: &str)

Source from the content-addressed store, hash-verified

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 {

Callers 8

put_metadata_targetMethod · 0.80
put_view_stateMethod · 0.80
put_git_headMethod · 0.80
put_git_ref_targetMethod · 0.80
put_actorMethod · 0.80
put_loss_noteMethod · 0.80
put_effect_targetMethod · 0.80

Calls 5

put_u32Method · 0.80
put_bytesMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected