Return `(data_start, byte_len)` for the string at `offset` without validating UTF-8. Used internally for key comparison.
(buf: &[u8], offset: usize)
| 334 | /// Return `(data_start, byte_len)` for the string at `offset` without |
| 335 | /// validating UTF-8. Used internally for key comparison. |
| 336 | pub(crate) fn str_bounds(buf: &[u8], offset: usize) -> Option<(usize, usize)> { |
| 337 | let tag = get(buf, offset)?; |
| 338 | match tag { |
| 339 | 0xa0..=0xbf => { |
| 340 | let len = (tag & 0x1f) as usize; |
| 341 | Some((offset + 1, len)) |
| 342 | } |
| 343 | STR8 => { |
| 344 | let len = get(buf, offset + 1)? as usize; |
| 345 | Some((offset + 2, len)) |
| 346 | } |
| 347 | STR16 => { |
| 348 | let len = read_u16_be(buf, offset + 1)? as usize; |
| 349 | Some((offset + 3, len)) |
| 350 | } |
| 351 | STR32 => { |
| 352 | let len = read_u32_be(buf, offset + 1)? as usize; |
| 353 | Some((offset + 5, len)) |
| 354 | } |
| 355 | _ => None, |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | /// Read a boolean from the value at `offset`. |
| 360 | pub fn read_bool(buf: &[u8], offset: usize) -> Option<bool> { |
no test coverage detected