use std::path::Path;
use vectrust_core::*;
pub struct Storage;
impl Storage {
pub fn auto_detect(path: &Path, index_name: &str) -> Result<Box<dyn StorageBackend>> {
let index_path = path.join(index_name);
let manifest_path = path.join("manifest.json");
if manifest_path.exists() {
Ok(Box::new(crate::OptimizedStorage::new(path)?))
} else if index_path.exists() {
Ok(Box::new(crate::LegacyStorage::new(path, index_name)?))
} else {
Ok(Box::new(crate::OptimizedStorage::new(path)?))
}
}
}