1#![doc(html_root_url = "https://docs.rs/rpkg-rs/1.3.0")]
2use thiserror::Error;
15
16#[cfg(feature = "serde")]
17use serde::{Deserialize, Serialize};
18
19pub mod encryption;
20pub mod misc;
21pub mod resource;
22pub(crate) mod utils;
23
24#[derive(Debug, PartialEq, Clone, Copy)]
25#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
26pub enum WoaVersion {
27 HM2016,
28 HM2,
29 HM3,
30}
31
32#[derive(Debug, Error)]
33pub enum GlacierResourceError {
34 #[error("Error reading the file: {0}")]
35 IoError(#[from] std::io::Error),
36
37 #[error("Couldn't read the resource {0}")]
38 ReadError(String),
39
40 #[error("Couldn't write the resource {0}")]
41 WriteError(String),
42}
43
44pub trait GlacierResource: Sized {
45 type Output;
46 fn process_data<R: AsRef<[u8]>>(
47 woa_version: WoaVersion,
48 data: R,
49 ) -> Result<Self::Output, GlacierResourceError>;
50
51 fn serialize(&self, woa_version: WoaVersion) -> Result<Vec<u8>, GlacierResourceError>;
52
53 fn resource_type() -> [u8; 4];
54 fn video_memory_requirement(&self) -> u64;
55 fn system_memory_requirement(&self) -> u64;
56 fn should_scramble(&self) -> bool;
57 fn should_compress(&self) -> bool;
58}