Insert or overwrite an array catalog entry.
(&self, entry: &ArrayCatalogEntry)
| 16 | impl SystemCatalog { |
| 17 | /// Insert or overwrite an array catalog entry. |
| 18 | pub fn put_array(&self, entry: &ArrayCatalogEntry) -> crate::Result<()> { |
| 19 | let bytes = |
| 20 | zerompk::to_msgpack_vec(entry).map_err(|e| catalog_err("serialize array", e))?; |
| 21 | let write_txn = self |
| 22 | .db |
| 23 | .begin_write() |
| 24 | .map_err(|e| catalog_err("write txn", e))?; |
| 25 | { |
| 26 | let mut table = write_txn |
| 27 | .open_table(ARRAYS) |
| 28 | .map_err(|e| catalog_err("open arrays", e))?; |
| 29 | table |
| 30 | .insert(entry.name.as_str(), bytes.as_slice()) |
| 31 | .map_err(|e| catalog_err("insert array", e))?; |
| 32 | } |
| 33 | write_txn.commit().map_err(|e| catalog_err("commit", e)) |
| 34 | } |
| 35 | |
| 36 | /// Fetch one entry by name. |
| 37 | pub fn get_array(&self, name: &str) -> crate::Result<Option<ArrayCatalogEntry>> { |
no test coverage detected