use std::path::PathBuf; use crate::murmur::{Dictionary, HashGroup, IdString64, Murmur32, Murmur64}; pub struct Context { pub lookup: Dictionary, pub ljd: Option, pub revorb: Option, pub ww2ogg: Option, pub game_dir: Option, } impl Context { pub fn new() -> Self { Self { lookup: Dictionary::new(), ljd: None, revorb: None, ww2ogg: None, game_dir: None, } } pub fn lookup_hash(&self, hash: M, group: HashGroup) -> IdString64 where M: Into, { let hash = hash.into(); if let Some(s) = self.lookup.lookup(hash, group) { tracing::debug!(%hash, string = s, "Murmur64 lookup successful"); s.to_string().into() } else { tracing::debug!(%hash, "Murmur64 lookup failed"); hash.into() } } pub fn lookup_hash_short(&self, hash: M, group: HashGroup) -> String where M: Into, { let hash = hash.into(); if let Some(s) = self.lookup.lookup_short(hash, group) { tracing::debug!(%hash, string = s, "Murmur32 lookup successful"); s.to_owned() } else { tracing::debug!(%hash, "Murmur32 lookup failed"); format!("{hash:08X}") } } } impl Default for Context { fn default() -> Self { Self::new() } }