poe_data_tools 1.0.0

A library for working with Path of Exile game data
Documentation
use anyhow::Context;

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

pub mod parser;
pub mod types;
use parser::parse_epk_str;
use types::EPKFile;

pub struct EPKParser;

impl FileParser for EPKParser {
    type Output = EPKFile;

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

        parse_epk_str(&contents).unversioned()
    }
}