1use vortex::dtype::extension::ExtDTypeRef;
7use vortex::dtype::extension::Matcher;
8
9use crate::fixed_shape::FixedShapeTensor;
10use crate::fixed_shape::FixedShapeTensorMetadata;
11use crate::vector::Vector;
12
13pub struct AnyTensor;
20
21#[derive(Debug, PartialEq, Eq)]
23pub enum TensorMatch<'a> {
24 FixedShapeTensor(&'a FixedShapeTensorMetadata),
26 Vector,
28}
29
30impl Matcher for AnyTensor {
31 type Match<'a> = TensorMatch<'a>;
32
33 fn try_match<'a>(item: &'a ExtDTypeRef) -> Option<Self::Match<'a>> {
34 if let Some(metadata) = item.metadata_opt::<FixedShapeTensor>() {
35 return Some(TensorMatch::FixedShapeTensor(metadata));
36 }
37 if item.metadata_opt::<Vector>().is_some() {
38 return Some(TensorMatch::Vector);
39 }
40 None
41 }
42}