vortex_array/vtable/
serde.rs1use vortex_dtype::DType;
2use vortex_error::{VortexExpect, VortexResult, vortex_bail};
3
4use crate::serde::ArrayParts;
5use crate::{Array, ArrayContext, ArrayRef, Encoding};
6
7pub trait SerdeVTable<Array> {
9 fn decode(
11 &self,
12 parts: &ArrayParts,
13 ctx: &ArrayContext,
14 _dtype: DType,
15 _len: usize,
16 ) -> VortexResult<ArrayRef> {
17 vortex_bail!(
18 "Decoding not supported for encoding {}",
19 ctx.lookup_encoding(parts.encoding_id())
20 .vortex_expect("Encoding already validated")
21 .id()
22 )
23 }
24}
25
26impl<'a, E: Encoding> SerdeVTable<&'a dyn Array> for E
27where
28 E: SerdeVTable<&'a E::Array>,
29{
30 fn decode(
31 &self,
32 parts: &ArrayParts,
33 ctx: &ArrayContext,
34 dtype: DType,
35 len: usize,
36 ) -> VortexResult<ArrayRef> {
37 <E as SerdeVTable<&'a E::Array>>::decode(self, parts, ctx, dtype, len)
38 }
39}