#![warn(missing_docs)]
use error::{Error, Result};
use parser::Analysis;
use serde::Serialize;
pub mod error;
pub mod parser;
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct Rawfile<'a> {
pub analyses: Vec<Analysis<'a>>,
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Options {
pub endianness: ByteOrder,
}
impl Default for Options {
#[inline]
fn default() -> Self {
Self {
endianness: ByteOrder::BigEndian,
}
}
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum ByteOrder {
BigEndian,
LittleEndian,
}
pub fn parse<T>(input: &T, options: Options) -> Result<Rawfile<'_>>
where
T: AsRef<[u8]>,
{
match parser::analyses(input.as_ref(), options) {
Ok((_, analyses)) => Ok(Rawfile { analyses }),
Err(_) => Err(Error::Parse),
}
}