flow_record_common/
record_field.rs

1use getset::Getters;
2use rmpv::Value;
3
4use crate::FieldType;
5
6#[derive(Clone, Eq, PartialEq, Debug, Hash, Getters)]
7#[getset(get = "pub")]
8pub struct RecordField {
9    field_name: String,
10    field_type: FieldType,
11}
12
13impl RecordField {
14    pub fn dissolve(self) -> (String, FieldType) {
15        (self.field_name, self.field_type)
16    }
17}
18
19impl From<(String, FieldType)> for RecordField {
20    fn from(value: (String, FieldType)) -> Self {
21        Self {
22            field_name: value.0,
23            field_type: value.1,
24        }
25    }
26}
27
28impl From<RecordField> for Value {
29    fn from(value: RecordField) -> Self {
30        Value::Array(vec![
31            value.field_type.into(),
32            Value::String(value.field_name.into()),
33        ])
34    }
35}