use crate::error::Error;
pub struct Family {
pub id: u8,
pub name: &'static str,
#[allow(dead_code)] pub min_pre_longs: u8,
#[allow(dead_code)] pub max_pre_longs: u8,
}
impl Family {
#[cfg(feature = "theta")]
pub const THETA: Family = Family {
id: 3,
name: "THETA",
min_pre_longs: 1,
max_pre_longs: 3,
};
#[cfg(feature = "hll")]
pub const HLL: Family = Family {
id: 7,
name: "HLL",
min_pre_longs: 1,
max_pre_longs: 1,
};
#[cfg(feature = "frequencies")]
pub const FREQUENCY: Family = Family {
id: 10,
name: "FREQUENCY",
min_pre_longs: 1,
max_pre_longs: 4,
};
#[cfg(feature = "cpc")]
pub const CPC: Family = Family {
id: 16,
name: "CPC",
min_pre_longs: 1,
max_pre_longs: 5,
};
#[cfg(feature = "countmin")]
pub const COUNTMIN: Family = Family {
id: 18,
name: "COUNTMIN",
min_pre_longs: 2,
max_pre_longs: 2,
};
#[cfg(feature = "tdigest")]
pub const TDIGEST: Family = Family {
id: 20,
name: "TDIGEST",
min_pre_longs: 1,
max_pre_longs: 2,
};
#[cfg(feature = "bloom")]
pub const BLOOMFILTER: Family = Family {
id: 21,
name: "BLOOMFILTER",
min_pre_longs: 3,
max_pre_longs: 4,
};
}
impl Family {
pub fn validate_id(&self, family_id: u8) -> Result<(), Error> {
if family_id != self.id {
Err(Error::invalid_family(self.id, family_id, self.name))
} else {
Ok(())
}
}
}