use vortex_error::{VortexError, VortexExpect, VortexResult};
use crate::encoding::Encoding;
use crate::Array;
pub trait ValidateVTable<Array> {
fn validate(&self, _array: &Array) -> VortexResult<()> {
Ok(())
}
}
impl<E: Encoding> ValidateVTable<Array> for E
where
E: ValidateVTable<E::Array>,
for<'a> &'a E::Array: TryFrom<&'a Array, Error = VortexError>,
{
fn validate(&self, array: &Array) -> VortexResult<()> {
let (array_ref, encoding) = array
.try_downcast_ref::<E>()
.vortex_expect("Failed to downcast encoding");
encoding.validate(array_ref)
}
}