vecdb/traits/
any_readable.rs1use crate::{AnyVec, ReadableVec, TypedVec, i64_to_usize};
2
3pub trait AnyReadableVec: AnyVec {
5 fn range_count(&self, from: Option<i64>, to: Option<i64>) -> usize {
7 let len = self.len();
8 let from = from.map(|i| i64_to_usize(i, len)).unwrap_or_default();
9 let to = to.map(|i| i64_to_usize(i, len)).unwrap_or(len);
10 to.saturating_sub(from)
11 }
12
13 fn range_weight(&self, from: Option<i64>, to: Option<i64>) -> usize {
15 self.range_count(from, to) * self.value_type_to_size_of()
16 }
17}
18
19impl<V> AnyReadableVec for V
20where
21 V: TypedVec,
22 V: ReadableVec<V::I, V::T>,
23{
24}