Read an i64 from the value at `offset`. Handles all integer types. Floats return `None` — use `read_f64` for those.
(buf: &[u8], offset: usize)
| 243 | /// Read an i64 from the value at `offset`. Handles all integer types. |
| 244 | /// Floats return `None` — use `read_f64` for those. |
| 245 | pub fn read_i64(buf: &[u8], offset: usize) -> Option<i64> { |
| 246 | let tag = get(buf, offset)?; |
| 247 | match tag { |
| 248 | 0x00..=0x7f => Some(tag as i64), |
| 249 | 0xe0..=0xff => Some((tag as i8) as i64), |
| 250 | UINT8 => Some(get(buf, offset + 1)? as i64), |
| 251 | UINT16 => Some(read_u16_be(buf, offset + 1)? as i64), |
| 252 | UINT32 => Some(read_u32_be(buf, offset + 1)? as i64), |
| 253 | UINT64 => { |
| 254 | let v = read_u64_be(buf, offset + 1)?; |
| 255 | Some(v as i64) |
| 256 | } |
| 257 | INT8 => Some(get(buf, offset + 1)? as i8 as i64), |
| 258 | INT16 => Some(read_u16_be(buf, offset + 1)? as i16 as i64), |
| 259 | INT32 => Some(read_u32_be(buf, offset + 1)? as i32 as i64), |
| 260 | INT64 => { |
| 261 | let v = read_u64_be(buf, offset + 1)?; |
| 262 | Some(v as i64) |
| 263 | } |
| 264 | _ => None, |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /// Read a string slice from the value at `offset`. Zero-copy — borrows |
| 269 | /// directly from the input buffer. Returns `None` for non-string types |