Read and validate the header, then return the schema version. Validates magic bytes at [0..4] and format version at [4] before returning the schema version at [5..9].
(&self, tuple: &[u8])
| 72 | /// Validates magic bytes at [0..4] and format version at [4] before |
| 73 | /// returning the schema version at [5..9]. |
| 74 | pub fn schema_version(&self, tuple: &[u8]) -> Result<u32, StrictError> { |
| 75 | if tuple.len() < 9 { |
| 76 | return Err(StrictError::TruncatedTuple { |
| 77 | expected: 9, |
| 78 | got: tuple.len(), |
| 79 | }); |
| 80 | } |
| 81 | let got_magic = u32::from_le_bytes([tuple[0], tuple[1], tuple[2], tuple[3]]); |
| 82 | if got_magic != MAGIC { |
| 83 | return Err(StrictError::InvalidMagic { |
| 84 | expected: MAGIC, |
| 85 | got: got_magic, |
| 86 | }); |
| 87 | } |
| 88 | let got_version = tuple[4]; |
| 89 | if got_version != FORMAT_VERSION { |
| 90 | return Err(StrictError::InvalidFormatVersion { |
| 91 | expected: FORMAT_VERSION, |
| 92 | got: got_version, |
| 93 | }); |
| 94 | } |
| 95 | Ok(u32::from_le_bytes([tuple[5], tuple[6], tuple[7], tuple[8]])) |
| 96 | } |
| 97 | |
| 98 | /// Check whether column `col_idx` is null in the given tuple. |
| 99 | pub fn is_null(&self, tuple: &[u8], col_idx: usize) -> Result<bool, StrictError> { |