mod decode;
mod encode;
mod matrix;
mod tables;
pub use decode::RmqrDecoder;
pub use encode::RmqrEncoder;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct RmqrSize(u8);
impl RmqrSize {
pub fn from_indicator(vi: u8) -> Option<Self> {
(vi < 32).then_some(RmqrSize(vi))
}
pub fn from_dimensions(width: usize, height: usize) -> Option<Self> {
(0..32u8).find_map(|vi| {
let info = &tables::SIZES[vi as usize];
(info.width == width && info.height == height).then_some(RmqrSize(vi))
})
}
pub fn indicator(self) -> u8 {
self.0
}
pub fn width(self) -> usize {
tables::SIZES[self.0 as usize].width
}
pub fn height(self) -> usize {
tables::SIZES[self.0 as usize].height
}
pub fn name(self) -> String {
format!("R{}x{}", self.height(), self.width())
}
pub fn all() -> impl Iterator<Item = RmqrSize> {
(0..32u8).map(RmqrSize)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum RmqrEcLevel {
M,
H,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RmqrMeta {
pub size: RmqrSize,
pub ec_level: RmqrEcLevel,
}