use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Field {
pub key: String,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct Entry {
pub key: String,
pub entry_type: String,
pub start_line: u32,
pub fields: Vec<Field>,
}
impl Entry {
pub fn field(&self, name: &str) -> Option<&Field> {
self.fields
.iter()
.find(|f| f.key.eq_ignore_ascii_case(name))
}
}
#[derive(Debug, Clone)]
pub struct DuplicateBlockKey {
pub key: String,
pub start_line: u32,
pub entry: Entry,
}
#[derive(Debug, Clone)]
pub struct DuplicateFieldKey {
pub start_line: u32,
pub duplicate_keys: Vec<String>,
pub entry: Entry,
}
#[derive(Debug, Clone, Default)]
pub struct Library {
pub entries: Vec<Entry>,
pub duplicate_block_keys: Vec<DuplicateBlockKey>,
pub duplicate_field_keys: Vec<DuplicateFieldKey>,
}
pub(crate) type StringTable = HashMap<String, String>;