Load the metadata for a change. This reads only from CHANGE_META — the cheapest possible read. Useful for `atomic log`, header inspection, dependency resolution.
(&self, hash: &[u8; 32])
| 408 | /// This reads only from CHANGE_META — the cheapest possible read. |
| 409 | /// Useful for `atomic log`, header inspection, dependency resolution. |
| 410 | pub fn load_meta(&self, hash: &[u8; 32]) -> RedbStoreResult<StoredChangeMeta> { |
| 411 | let txn = self.db.begin_read()?; |
| 412 | let table = txn.open_table(tables::CHANGE_META)?; |
| 413 | |
| 414 | let value = table.get(hash)?.ok_or_else(|| RedbStoreError::NotFound { |
| 415 | hash: format!( |
| 416 | "{:02x}{:02x}{:02x}{:02x}…", |
| 417 | hash[0], hash[1], hash[2], hash[3] |
| 418 | ), |
| 419 | })?; |
| 420 | |
| 421 | let compressed = value.value(); |
| 422 | let decompressed = zstd::decode_all(compressed) |
| 423 | .map_err(|e| RedbStoreError::Corrupt(format!("meta decompression failed: {}", e)))?; |
| 424 | let meta: StoredChangeMeta = postcard::from_bytes(&decompressed) |
| 425 | .map_err(|e| RedbStoreError::Corrupt(format!("meta deserialization failed: {}", e)))?; |
| 426 | |
| 427 | Ok(meta) |
| 428 | } |
| 429 | |
| 430 | // NOTE: load_change(), export_v3_file(), export_v3_bytes(), and |
| 431 | // delete_change() are in queries.rs |