Read a string slice at `*off`, advancing `*off` past it. Zero-copy. Returns `None` for non-string types, invalid UTF-8, or truncated input.
(buf: &'a [u8], off: &mut usize)
| 277 | /// Read a string slice at `*off`, advancing `*off` past it. Zero-copy. |
| 278 | /// Returns `None` for non-string types, invalid UTF-8, or truncated input. |
| 279 | pub fn read_str_advance<'a>(buf: &'a [u8], off: &mut usize) -> Option<&'a str> { |
| 280 | let (start, len) = str_bounds(buf, *off)?; |
| 281 | let bytes = buf.get(start..start + len)?; |
| 282 | let s = str::from_utf8(bytes).ok()?; |
| 283 | *off = start + len; |
| 284 | Some(s) |
| 285 | } |
| 286 | |
| 287 | /// Read a `bin` value at `*off`, advancing `*off` past it. Zero-copy — |
| 288 | /// the returned slice borrows from `buf`. Returns `None` for non-bin tags |
no test coverage detected