mod descriptor;
mod reader;
pub mod sections;
pub mod tables;
pub use descriptor::*;
pub use reader::{DataEvent, DataReader, DataSpec};
pub use sections::{HeaderSections, ensure_end_section};
pub use tables::{TableBEntry, TableDEntry, Tables};
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("Table error: {0}")]
Table(String),
#[error("Invalid data: {0}")]
Invalid(String),
#[error("Not supported: {0}")]
NotSupported(String),
#[error("Fatal error: {0}")]
Fatal(String),
}
#[derive(Clone, PartialEq, Eq)]
pub enum Value {
Missing,
Decimal(i32, i8),
Integer(i32),
String(String),
}
impl std::fmt::Debug for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Value::Missing => write!(f, "Missing"),
&Value::Decimal(v, s) => {
write!(
f,
"{:.1$}",
v as f64 * 10f64.powi(s as i32),
if s < 0 { -s } else { 0 } as usize
)
}
Value::Integer(v) => write!(f, "{v}"),
Value::String(s) => write!(f, "\"{s}\""),
}
}
}