poe_data_tools 1.0.0

A library for working with Path of Exile game data
Documentation
pub mod parser;
pub mod types;
use anyhow::Context;
use parser::parse_mat_str;
use types::MATFile;

use crate::file_parsers::{
    FileParser, VersionedResult, VersionedResultExt, shared::utf16_bom_to_string,
};

pub struct MATParser;

impl FileParser for MATParser {
    type Output = MATFile;

    fn parse(&self, bytes: &[u8]) -> VersionedResult<Self::Output> {
        let contents = utf16_bom_to_string(bytes)
            .or_else(|_| String::from_utf16le(bytes).context("Failed to parse as UTF16-LE"))?;

        parse_mat_str(&contents).unversioned()
    }
}