Read a string slice from the value at `offset`. Zero-copy — borrows directly from the input buffer. Returns `None` for non-string types or invalid UTF-8.
(buf: &[u8], offset: usize)
| 269 | /// directly from the input buffer. Returns `None` for non-string types |
| 270 | /// or invalid UTF-8. |
| 271 | pub fn read_str(buf: &[u8], offset: usize) -> Option<&str> { |
| 272 | let (start, len) = str_bounds(buf, offset)?; |
| 273 | let bytes = buf.get(start..start + len)?; |
| 274 | str::from_utf8(bytes).ok() |
| 275 | } |
| 276 | |
| 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. |