use crate::field_map::FieldMap;
pub trait GroupSpec {
fn group_of(&self, count_tag: u32) -> Option<(u32, &[u32])>;
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Group {
count_tag: u32,
entries: Vec<FieldMap>,
declared_count: Option<i64>,
}
impl Group {
pub fn new(count_tag: u32) -> Self {
Self {
count_tag,
entries: Vec::new(),
declared_count: None,
}
}
pub fn add_entry(&mut self, entry: FieldMap) -> &mut Self {
self.entries.push(entry);
self
}
pub fn count_tag(&self) -> u32 {
self.count_tag
}
pub fn len(&self) -> usize {
self.entries.len()
}
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
pub(crate) fn set_declared_count(&mut self, n: i64) {
self.declared_count = Some(n);
}
pub(crate) fn into_parts(self) -> (u32, Vec<FieldMap>, Option<i64>) {
(self.count_tag, self.entries, self.declared_count)
}
}