use velesdb_core::{Database, GraphCollection, MetadataCollection, VectorCollection};
pub enum TypedCollection {
Vector(VectorCollection),
Graph(GraphCollection),
Metadata(MetadataCollection),
}
#[must_use]
pub fn resolve_collection(db: &Database, name: &str) -> Option<TypedCollection> {
if let Some(c) = db.get_vector_collection(name) {
return Some(TypedCollection::Vector(c));
}
if let Some(c) = db.get_graph_collection(name) {
return Some(TypedCollection::Graph(c));
}
if let Some(c) = db.get_metadata_collection(name) {
return Some(TypedCollection::Metadata(c));
}
None
}
#[must_use]
pub fn collection_type_label(db: &Database, name: &str) -> &'static str {
if db.get_vector_collection(name).is_some() {
return "Vector";
}
if db.get_graph_collection(name).is_some() {
return "Graph";
}
if db.get_metadata_collection(name).is_some() {
return "Metadata";
}
"unknown"
}
#[cfg(test)]
#[path = "collection_helpers_tests.rs"]
mod collection_helpers_tests;