use std::borrow::Borrow;
use bitvec::vec::BitVec;
use super::{Array, ArrayImpl};
use crate::for_all_variants;
pub trait ArrayValidExt: Array {
fn get_valid_bitmap(&self) -> &BitVec;
fn get_valid_bitmap_mut(&mut self) -> &mut BitVec;
}
pub trait ArrayImplValidExt {
fn get_valid_bitmap(&self) -> &BitVec;
}
pub trait ArrayEstimateExt: Array {
fn get_estimated_size(&self) -> usize;
}
pub trait ArrayImplEstimateExt {
fn get_estimated_size(&self) -> usize;
}
pub trait ArrayFromDataExt: Array {
fn from_data(data_iter: impl Iterator<Item = impl Borrow<Self::Item>>, valid: BitVec) -> Self;
}
macro_rules! impl_array_impl_internal_ext {
([], $( { $Abc:ident, $Type:ty, $abc:ident, $AbcArray:ty, $AbcArrayBuilder:ty, $Value:ident, $Pattern:pat } ),*) => {
impl ArrayImplValidExt for ArrayImpl {
fn get_valid_bitmap(&self) -> &BitVec {
match self {
$(
Self::$Abc(a) => a.get_valid_bitmap(),
)*
}
}
}
impl ArrayImplEstimateExt for ArrayImpl {
fn get_estimated_size(&self) -> usize {
match self {
$(
Self::$Abc(a) => a.get_estimated_size(),
)*
}
}
}
}
}
for_all_variants! { impl_array_impl_internal_ext }