1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use arrow2::datatypes::Field;
use arrow2_convert::{
deserialize::{ArrowArray, ArrowDeserialize},
field::ArrowField,
serialize::ArrowSerialize,
};
use crate::ComponentName;
pub trait Component: ArrowField {
fn name() -> ComponentName;
fn field() -> Field {
Field::new(Self::name().as_str(), Self::data_type(), false)
}
}
pub trait SerializableComponent<ArrowFieldType = Self>
where
Self: Component + ArrowSerialize + ArrowField<Type = Self> + 'static,
{
}
impl<C> SerializableComponent for C where
C: Component + ArrowSerialize + ArrowField<Type = C> + 'static
{
}
pub trait DeserializableComponent<ArrowFieldType = Self>
where
Self: Component,
Self: ArrowDeserialize + ArrowField<Type = ArrowFieldType> + 'static,
Self::ArrayType: ArrowArray,
for<'b> &'b Self::ArrayType: IntoIterator,
{
}
impl<C> DeserializableComponent for C
where
C: Component,
C: ArrowDeserialize + ArrowField<Type = C> + 'static,
C::ArrayType: ArrowArray,
for<'b> &'b C::ArrayType: IntoIterator,
{
}