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

Function encode_len_prefixed

atomic-core/src/pristine/ref_mapping.rs:359–371  ·  view source on GitHub ↗
(bytes: &mut Vec<u8>, value: &[u8])

Source from the content-addressed store, hash-verified

357}
358
359fn encode_len_prefixed(bytes: &mut Vec<u8>, value: &[u8]) -> PristineResult<()> {
360 if value.len() > u16::MAX as usize {
361 return Err(PristineError::Serialization {
362 message: format!(
363 "ref mapping field of {} bytes exceeds the u16-length encoding limit",
364 value.len()
365 ),
366 });
367 }
368 bytes.extend_from_slice(&(value.len() as u16).to_le_bytes());
369 bytes.extend_from_slice(value);
370 Ok(())
371}
372
373fn encode_option_ref(bytes: &mut Vec<u8>, value: Option<&str>) -> PristineResult<()> {
374 match value {

Callers 2

encodeMethod · 0.85
encode_option_refFunction · 0.85

Calls 2

to_le_bytesMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected