Read a single column's data from a packed file using byte range. When `footer.payload_encrypted` is true, `kek` must be `Some`; the payload region (everything before the footer body) is decrypted first, then the column range is extracted from the plaintext. The NDPK footer itself is always plaintext.
(
file_path: &Path,
footer: &PackedFooter,
column_name: &str,
kek: Option<&WalEncryptionKey>,
)
| 335 | /// column range is extracted from the plaintext. The NDPK footer itself is |
| 336 | /// always plaintext. |
| 337 | pub fn read_column( |
| 338 | file_path: &Path, |
| 339 | footer: &PackedFooter, |
| 340 | column_name: &str, |
| 341 | kek: Option<&WalEncryptionKey>, |
| 342 | ) -> Result<Vec<u8>, PackedError> { |
| 343 | let (offset, length) = footer |
| 344 | .column_ranges |
| 345 | .get(column_name) |
| 346 | .ok_or_else(|| PackedError::Corrupt(format!("column '{column_name}' not in footer")))?; |
| 347 | |
| 348 | let data = std::fs::read(file_path).map_err(|e| PackedError::Io(format!("read: {e}")))?; |
| 349 | read_column_from_bytes(&data, footer, *offset, *length, kek) |
| 350 | } |
| 351 | |
| 352 | /// Read a single column from in-memory file bytes (for testing). |
| 353 | fn read_column_from_bytes( |