use super::protocol::{Response, ResponsePayload};
use super::server::TreeMap;
#[derive(Debug)]
pub(crate) struct CollectionMeta {
pub name: String,
pub partition_name: String,
pub hashname: u64,
pub typ_hash: u64,
pub version: u16,
pub count: u64,
}
pub(crate) fn list_collections(trees: &TreeMap) -> Response {
let collections = trees
.iter()
.map(|(&hashname, handler)| {
let (typ_hash, version) = handler.info();
let count = handler.count(false).unwrap_or(0);
CollectionMeta {
name: handler.name().to_string(),
partition_name: handler.partition_name(),
hashname,
typ_hash,
version,
count,
}
})
.collect();
Response::Ok(ResponsePayload::Collections(collections))
}