pub mod index;
pub mod item;
pub mod node;
pub enum ResourceType {
MeshesAnimationsMaterials,
Textures,
MusicSound,
Text,
Characters,
}
pub enum ResourceFormat {
IndexFile,
AssetDatabase,
}
pub fn get_resource_filename(res_type: ResourceType, res_format: ResourceFormat) -> String {
format!(
"{}.{}",
match res_type {
ResourceType::MeshesAnimationsMaterials => "data0",
ResourceType::Textures => "data1",
ResourceType::MusicSound => "data2",
ResourceType::Text => "data5",
ResourceType::Characters => "characters",
},
match res_format {
ResourceFormat::IndexFile => "idx",
ResourceFormat::AssetDatabase => "sdb",
}
)
}
#[cfg(test)]
mod tests {
use super::{get_resource_filename, ResourceFormat, ResourceType};
#[test]
fn test_index_filenames() {
assert_eq!(
get_resource_filename(
ResourceType::MeshesAnimationsMaterials,
ResourceFormat::IndexFile
),
"data0.idx"
);
assert_eq!(
get_resource_filename(ResourceType::Textures, ResourceFormat::IndexFile),
"data1.idx"
);
assert_eq!(
get_resource_filename(ResourceType::MusicSound, ResourceFormat::IndexFile),
"data2.idx"
);
assert_eq!(
get_resource_filename(ResourceType::Text, ResourceFormat::IndexFile),
"data5.idx"
);
assert_eq!(
get_resource_filename(ResourceType::Characters, ResourceFormat::IndexFile),
"characters.idx"
);
}
#[test]
fn test_database_filenames() {
assert_eq!(
get_resource_filename(
ResourceType::MeshesAnimationsMaterials,
ResourceFormat::AssetDatabase
),
"data0.sdb"
);
assert_eq!(
get_resource_filename(ResourceType::Textures, ResourceFormat::AssetDatabase),
"data1.sdb"
);
assert_eq!(
get_resource_filename(ResourceType::MusicSound, ResourceFormat::AssetDatabase),
"data2.sdb"
);
assert_eq!(
get_resource_filename(ResourceType::Text, ResourceFormat::AssetDatabase),
"data5.sdb"
);
assert_eq!(
get_resource_filename(ResourceType::Characters, ResourceFormat::AssetDatabase),
"characters.sdb"
);
}
}