Read a little-endian `u16` from `data` at `*cursor`, advancing the cursor.
(data: &[u8], cursor: &mut usize)
| 173 | |
| 174 | /// Read a little-endian `u16` from `data` at `*cursor`, advancing the cursor. |
| 175 | fn read_u16(data: &[u8], cursor: &mut usize) -> Option<u16> { |
| 176 | let end = *cursor + 2; |
| 177 | if end > data.len() { |
| 178 | return None; |
| 179 | } |
| 180 | let bytes: [u8; 2] = data[*cursor..end].try_into().ok()?; |
| 181 | *cursor = end; |
| 182 | Some(u16::from_le_bytes(bytes)) |
| 183 | } |
| 184 | |
| 185 | // ─── Tests ────────────────────────────────────────────────────────────────── |
| 186 |