(take: &mut Take<'a>)
| 384 | type Take<'a> = dyn FnMut(usize) -> Result<&'a [u8], PristineError> + 'a; |
| 385 | |
| 386 | fn 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 | |
| 392 | fn take_option_ref<'a>(take: &mut Take<'a>) -> Result<Option<String>, PristineError> { |
| 393 | match take(1)?[0] { |
no test coverage detected