Skip to main content

arrow_tiberius/arrow/
field.rs

1//! Arrow field metadata model.
2
3use arrow_schema::DataType;
4
5/// Reference to an Arrow source field used by a schema mapping.
6///
7/// This is this crate's mapped source-field metadata. It is not a replacement
8/// for `arrow_schema::Field`.
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct ArrowFieldRef {
11    index: usize,
12    name: String,
13    nullable: bool,
14    data_type: DataType,
15}
16
17impl ArrowFieldRef {
18    /// Creates an Arrow source field reference.
19    pub const fn new(index: usize, name: String, nullable: bool, data_type: DataType) -> Self {
20        Self {
21            index,
22            name,
23            nullable,
24            data_type,
25        }
26    }
27
28    /// Returns the Arrow field index.
29    pub const fn index(&self) -> usize {
30        self.index
31    }
32
33    /// Returns the Arrow field name.
34    pub fn name(&self) -> &str {
35        &self.name
36    }
37
38    /// Returns true when the Arrow field is nullable.
39    pub const fn nullable(&self) -> bool {
40        self.nullable
41    }
42
43    /// Returns the Arrow field data type.
44    pub const fn data_type(&self) -> &DataType {
45        &self.data_type
46    }
47}