lotus_lib/cache_pair/cache_pair.rs
1use std::path::PathBuf;
2
3use anyhow::Result;
4
5/// Cache pair trait.
6pub trait CachePair {
7    /// The magic number for the cache pair.
8    const MAGIC_NUMBER: u64 = 0x1867C64E;
9    /// The archive version for the cache pair.
10    const ARCHIVE_VERSION: u64 = 20;
11
12    /// Creates a new cache pair from the specified TOC and cache paths.
13    fn new(toc_path: PathBuf, cache_path: PathBuf, is_post_ensmallening: bool) -> Self;
14
15    /// Returns whether the package is post-ensmallening.
16    ///
17    /// This is used to determine how to decompress the data from before "The Great Ensmallening"
18    /// update of Warframe.
19    fn is_post_ensmallening(&self) -> bool;
20
21    /// Returns the Table of Contents (TOC) file path.
22    fn toc_path(&self) -> PathBuf;
23
24    /// Returns the cache file path.
25    fn cache_path(&self) -> PathBuf;
26
27    /// Reads the TOC file.
28    ///
29    /// # Errors
30    ///
31    /// Returns an error if the TOC file cannot be read.
32    fn read_toc(&mut self) -> Result<()>;
33
34    /// Unreads the TOC file.
35    ///
36    /// This is used to reset the TOC file to the beginning.
37    fn unread_toc(&mut self);
38}