#[cfg(feature = "vfs")]
pub mod assets_bin_vfs;
pub mod idx;
#[cfg(feature = "vfs")]
pub mod idx_vfs;
pub mod parser_utils;
#[cfg(feature = "vfs-mmap")]
pub mod pkg;
pub mod ship_config;
pub mod serialization;
pub mod translation_key;
#[cfg(feature = "vfs")]
pub mod wrappers;
use std::borrow::Cow;
use crate::Rc;
use crate::error::GameDataError;
use crate::game_params::types::Param;
use crate::game_types::GameParamId;
use crate::rpc::entitydefs::EntitySpec;
pub trait ResourceLoader {
fn localized_name_from_param(&self, param: &Param) -> Option<String>;
fn localized_name_from_id(&self, id: &translation_key::TranslationKey) -> Option<String>;
fn game_param_by_id(&self, id: GameParamId) -> Option<Rc<Param>>;
fn entity_specs(&self) -> &[EntitySpec];
}
pub use translation_key::TranslationKey;
pub use wows_core::Version;
pub trait DataFileLoader {
fn get(&self, path: &str) -> Result<Cow<'static, [u8]>, GameDataError>;
}
pub struct DataFileWithCallback<F> {
callback: F,
}
impl<F> DataFileWithCallback<F>
where
F: Fn(&str) -> Result<Cow<'static, [u8]>, GameDataError>,
{
pub fn new(callback: F) -> Self {
Self { callback }
}
}
impl<F> DataFileLoader for DataFileWithCallback<F>
where
F: Fn(&str) -> Result<Cow<'static, [u8]>, GameDataError>,
{
fn get(&self, path: &str) -> Result<Cow<'static, [u8]>, GameDataError> {
(self.callback)(path)
}
}