Strip the one-byte version prefix from an enveloped snapshot buffer. Returns a slice into `bytes` starting after the version byte, or an error if the buffer is empty or the version does not match [`LORO_FORMAT_VERSION`].
(bytes: &[u8])
| 215 | /// Returns a slice into `bytes` starting after the version byte, or an error |
| 216 | /// if the buffer is empty or the version does not match [`LORO_FORMAT_VERSION`]. |
| 217 | fn strip_envelope(bytes: &[u8]) -> ArrayResult<&[u8]> { |
| 218 | match bytes.first() { |
| 219 | None => Err(ArrayError::SegmentCorruption { |
| 220 | detail: "loro snapshot envelope is empty".into(), |
| 221 | }), |
| 222 | Some(&v) if v != LORO_FORMAT_VERSION => Err(ArrayError::LoroSnapshotVersionMismatch { |
| 223 | expected: LORO_FORMAT_VERSION, |
| 224 | got: v, |
| 225 | }), |
| 226 | Some(_) => Ok(&bytes[1..]), |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | // ─── Tests ─────────────────────────────────────────────────────────────────── |
| 231 |
no test coverage detected