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

Function take_string

atomic-core/src/pristine/ref_mapping.rs:386–390  ·  view source on GitHub ↗
(take: &mut Take<'a>)

Source from the content-addressed store, hash-verified

384type Take<'a> = dyn FnMut(usize) -> Result<&'a [u8], PristineError> + 'a;
385
386fn take_string<'a>(take: &mut Take<'a>) -> Result<String, PristineError> {
387 let length = u16::from_le_bytes(take(2)?.try_into().expect("fixed-size u16")) as usize;
388 let slice = take(length)?;
389 String::from_utf8(slice.to_vec()).map_err(|_| decode_error())
390}
391
392fn take_option_ref<'a>(take: &mut Take<'a>) -> Result<Option<String>, PristineError> {
393 match take(1)?[0] {

Callers 2

decodeMethod · 0.85
take_option_refFunction · 0.85

Calls 1

decode_errorFunction · 0.85

Tested by

no test coverage detected