#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum FieldType {
Int = 1,
Real = 2,
Char = 3,
String = 4,
IntList = 5,
RealList = 6,
StringList = 7,
Dna = 8,
}
impl FieldType {
pub fn from_name(name: &str) -> Option<Self> {
match name {
"INT" => Some(Self::Int),
"REAL" => Some(Self::Real),
"CHAR" => Some(Self::Char),
"STRING" => Some(Self::String),
"INT_LIST" => Some(Self::IntList),
"REAL_LIST" => Some(Self::RealList),
"STRING_LIST" => Some(Self::StringList),
"DNA" => Some(Self::Dna),
_ => None,
}
}
pub fn name(self) -> &'static str {
match self {
Self::Int => "INT",
Self::Real => "REAL",
Self::Char => "CHAR",
Self::String => "STRING",
Self::IntList => "INT_LIST",
Self::RealList => "REAL_LIST",
Self::StringList => "STRING_LIST",
Self::Dna => "DNA",
}
}
pub fn is_list(self) -> bool {
matches!(
self,
Self::String
| Self::IntList
| Self::RealList
| Self::StringList
| Self::Dna
)
}
pub fn list_element_size(self) -> usize {
match self {
Self::String | Self::Dna => 1,
Self::IntList => 8,
Self::RealList => 8,
Self::StringList => 1,
_ => 0,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct LineCounts {
pub count: i64,
pub max: i64,
pub total: i64,
}
#[derive(Debug, Clone)]
pub struct Provenance {
pub program: String,
pub version: String,
pub command: String,
pub date: String,
}
#[derive(Debug, Clone)]
pub struct Reference {
pub filename: String,
pub count: i64,
}