Skip to main content

weavatrix_search_vector/bundle/
mutable_api.rs

1use super::{reader, writer};
2use crate::error::SearchError;
3use crate::mutable::MutableVectorIndex;
4use std::path::Path;
5
6impl MutableVectorIndex {
7    /// Loads a complete mutable bundle. Legacy immutable vector snapshots are
8    /// accepted with empty metadata and deltas.
9    ///
10    /// # Errors
11    ///
12    /// Returns typed snapshot or storage errors.
13    pub fn load(path: impl AsRef<Path>) -> Result<Self, SearchError> {
14        reader::load_complete(path.as_ref()).map(|(mutable, _)| mutable)
15    }
16
17    /// Atomically saves base and sealed graphs, staged vectors, tombstones,
18    /// and metadata without forcing compaction.
19    ///
20    /// # Errors
21    ///
22    /// Returns a compaction or storage error.
23    pub fn save(&self, path: impl AsRef<Path>) -> Result<(), SearchError> {
24        writer::save_complete(self, None, path.as_ref())
25    }
26}