Parse how many bytes the original msgpack occupies in a sidecar buffer.
(buf: &[u8])
| 70 | |
| 71 | /// Parse how many bytes the original msgpack occupies in a sidecar buffer. |
| 72 | fn sidecar_msgpack_len(buf: &[u8]) -> Option<usize> { |
| 73 | if buf.len() < TRAILER_SIZE { |
| 74 | return None; |
| 75 | } |
| 76 | let entry_count = read_entry_count(buf)?; |
| 77 | let sidecar_size = (entry_count as usize) * ENTRY_SIZE + TRAILER_SIZE; |
| 78 | buf.len().checked_sub(sidecar_size) |
| 79 | } |
| 80 | |
| 81 | /// Read the entry count from the trailer (second-to-last field before magic). |
| 82 | fn read_entry_count(buf: &[u8]) -> Option<u16> { |
no test coverage detected