diff --git a/src/main.rs b/src/main.rs index a2ee639..6a96117 100644 --- a/src/main.rs +++ b/src/main.rs @@ -265,7 +265,7 @@ pub fn parse_script( } pub fn parse_script_from_archive<'a>( - file: &mut Box, + file: &mut Box, arg: &args::Arg, config: std::sync::Arc, archive: &Box, diff --git a/src/scripts/artemis/archive/pf2.rs b/src/scripts/artemis/archive/pf2.rs index b97426c..b495b17 100644 --- a/src/scripts/artemis/archive/pf2.rs +++ b/src/scripts/artemis/archive/pf2.rs @@ -132,14 +132,14 @@ struct Pf2EntryHeader { #[derive(Debug)] /// The Artemis PF2 archive script. -pub struct ArtemisPf2<'a, T: Read + Seek + std::fmt::Debug + 'a> { +pub struct ArtemisPf2<'a, T: Read + Seek + std::fmt::Debug + Send + Sync + 'a> { reader: Arc>, entries: Vec, output_ext: Option, _mark: std::marker::PhantomData<&'a ()>, } -impl<'a, T: Read + Seek + std::fmt::Debug + 'a> ArtemisPf2<'a, T> { +impl<'a, T: Read + Seek + std::fmt::Debug + Send + Sync + 'a> ArtemisPf2<'a, T> { /// Creates a new Artemis PF2 archive script. /// /// * `reader` - The reader for the archive. @@ -188,7 +188,7 @@ impl<'a, T: Read + Seek + std::fmt::Debug + 'a> ArtemisPf2<'a, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ArtemisPf2<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for ArtemisPf2<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -215,7 +215,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ArtemisPf2<'b, T> { )) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", @@ -242,14 +242,14 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ArtemisPf2<'b, T> { } } -struct Pf2Entry { +struct Pf2Entry { header: Pf2EntryHeader, reader: Arc>, pos: u64, script_type: Option, } -impl ArchiveContent for Pf2Entry { +impl ArchiveContent for Pf2Entry { fn name(&self) -> &str { &self.header.name } @@ -259,7 +259,7 @@ impl ArchiveContent for Pf2Entry { } } -impl Read for Pf2Entry { +impl Read for Pf2Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -279,7 +279,7 @@ impl Read for Pf2Entry { } } -impl Seek for Pf2Entry { +impl Seek for Pf2Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset, diff --git a/src/scripts/artemis/archive/pfs.rs b/src/scripts/artemis/archive/pfs.rs index a46b65b..6e45956 100644 --- a/src/scripts/artemis/archive/pfs.rs +++ b/src/scripts/artemis/archive/pfs.rs @@ -131,7 +131,7 @@ struct PfsEntryHeader { #[derive(Debug)] /// The Artemis PFS archive script. -pub struct ArtemisArc<'a, T: Read + Seek + std::fmt::Debug + 'a> { +pub struct ArtemisArc<'a, T: Read + Seek + std::fmt::Debug + Send + Sync + 'a> { reader: Arc>, entries: Vec, xor_key: Option<[u8; 20]>, @@ -139,7 +139,7 @@ pub struct ArtemisArc<'a, T: Read + Seek + std::fmt::Debug + 'a> { _mark: std::marker::PhantomData<&'a ()>, } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> ArtemisArc<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> ArtemisArc<'b, T> { /// Creates a new Artemis PFS archive script. /// /// * `reader` - The reader for the archive. @@ -202,7 +202,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> ArtemisArc<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ArtemisArc<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for ArtemisArc<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -229,7 +229,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ArtemisArc<'b, T> { )) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/base.rs b/src/scripts/base.rs index a61dfd8..844eb4e 100644 --- a/src/scripts/base.rs +++ b/src/scripts/base.rs @@ -262,7 +262,7 @@ pub trait ArchiveContent: Read { Ok(data) } /// Returns a reader that supports reading and seeking. - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(MemReader::new(self.data()?))) } } @@ -460,7 +460,10 @@ pub trait Script: std::fmt::Debug { } /// Opens a file in the archive by its index. - fn open_file<'a>(&'a self, _index: usize) -> Result> { + fn open_file<'a>( + &'a self, + _index: usize, + ) -> Result> { Err(anyhow::anyhow!( "This script type does not support opening files." )) @@ -474,7 +477,7 @@ pub trait Script: std::fmt::Debug { &'a self, name: &str, ignore_case: bool, - ) -> Result> { + ) -> Result> { for (i, fname) in self.iter_archive_filename()?.enumerate() { if let Ok(fname) = fname { if fname == name || (ignore_case && fname.eq_ignore_ascii_case(name)) { @@ -489,7 +492,10 @@ pub trait Script: std::fmt::Debug { } /// Opens a file in the archive by its offset. - fn open_file_by_offset<'a>(&'a self, offset: u64) -> Result> { + fn open_file_by_offset<'a>( + &'a self, + offset: u64, + ) -> Result> { for (i, off) in self.iter_archive_offset()?.enumerate() { if let Ok(off) = off { if off == offset { diff --git a/src/scripts/bgi/archive/v1.rs b/src/scripts/bgi/archive/v1.rs index c5adb18..9407756 100644 --- a/src/scripts/bgi/archive/v1.rs +++ b/src/scripts/bgi/archive/v1.rs @@ -273,7 +273,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> BgiArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for BgiArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for BgiArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -298,7 +298,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for BgiArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", @@ -488,7 +488,7 @@ impl Option<&'static ScriptType>> ArchiveContent fo Ok(self.data.data.clone()) } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(&mut self.data)) } } diff --git a/src/scripts/bgi/archive/v2.rs b/src/scripts/bgi/archive/v2.rs index 2d08b76..d96c331 100644 --- a/src/scripts/bgi/archive/v2.rs +++ b/src/scripts/bgi/archive/v2.rs @@ -244,7 +244,7 @@ impl Option<&'static ScriptType>> ArchiveContent fo Ok(self.data.data.clone()) } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(&mut self.data)) } } @@ -305,7 +305,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> BgiArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for BgiArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for BgiArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -330,7 +330,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for BgiArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/cat_system/archive/int.rs b/src/scripts/cat_system/archive/int.rs index dee20af..2cb1bb7 100644 --- a/src/scripts/cat_system/archive/int.rs +++ b/src/scripts/cat_system/archive/int.rs @@ -236,7 +236,7 @@ impl ArchiveContent for MemEntry { Ok(self.data.data.clone()) } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(&mut self.data)) } } @@ -395,7 +395,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> CSIntArc<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for CSIntArc<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for CSIntArc<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -418,7 +418,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for CSIntArc<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/circus/archive/crm.rs b/src/scripts/circus/archive/crm.rs index 5693afd..422f464 100644 --- a/src/scripts/circus/archive/crm.rs +++ b/src/scripts/circus/archive/crm.rs @@ -233,7 +233,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> CrmArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for CrmArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for CrmArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -256,7 +256,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for CrmArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/circus/archive/dat.rs b/src/scripts/circus/archive/dat.rs index 178df44..ed5f14a 100644 --- a/src/scripts/circus/archive/dat.rs +++ b/src/scripts/circus/archive/dat.rs @@ -267,7 +267,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> DatArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for DatArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for DatArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -290,7 +290,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for DatArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/circus/archive/pck.rs b/src/scripts/circus/archive/pck.rs index 623eb4a..3c21de2 100644 --- a/src/scripts/circus/archive/pck.rs +++ b/src/scripts/circus/archive/pck.rs @@ -259,7 +259,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> PckArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for PckArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for PckArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -282,7 +282,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for PckArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|e| Ok(e.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/escude/archive.rs b/src/scripts/escude/archive.rs index bcaa8e6..b75de64 100644 --- a/src/scripts/escude/archive.rs +++ b/src/scripts/escude/archive.rs @@ -158,7 +158,7 @@ impl ArchiveContent for Entry { Ok(self.data.data.clone()) } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(&mut self.data)) } } @@ -240,7 +240,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for EscudeBinArchive<'b, )) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})", diff --git a/src/scripts/ex_hibit/arc/grp.rs b/src/scripts/ex_hibit/arc/grp.rs index 3c34e86..5184e6a 100644 --- a/src/scripts/ex_hibit/arc/grp.rs +++ b/src/scripts/ex_hibit/arc/grp.rs @@ -159,7 +159,7 @@ impl<'b, T: Read + Seek + Debug + 'b> ExHibitGrpArchive<'b, T> { } } -impl<'b, T: Read + Seek + Debug + 'b> Script for ExHibitGrpArchive<'b, T> { +impl<'b, T: Read + Seek + Debug + Send + Sync + 'b> Script for ExHibitGrpArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -184,7 +184,7 @@ impl<'b, T: Read + Seek + Debug + 'b> Script for ExHibitGrpArchive<'b, T> { Ok(Box::new(self.entries.iter().map(|entry| Ok(entry.offset)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {}).", diff --git a/src/scripts/hexen_haus/archive/arcc.rs b/src/scripts/hexen_haus/archive/arcc.rs index 446e34e..0197bd3 100644 --- a/src/scripts/hexen_haus/archive/arcc.rs +++ b/src/scripts/hexen_haus/archive/arcc.rs @@ -216,7 +216,9 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> HexenHausArccArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausArccArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script + for HexenHausArccArchive<'b, T> +{ fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -241,7 +243,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausArccArchive< Ok(Box::new(self.entries.iter().map(|entry| Ok(entry.offset)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (total files: {})", diff --git a/src/scripts/hexen_haus/archive/odio.rs b/src/scripts/hexen_haus/archive/odio.rs index 93be839..94b2ecd 100644 --- a/src/scripts/hexen_haus/archive/odio.rs +++ b/src/scripts/hexen_haus/archive/odio.rs @@ -227,7 +227,9 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> HexenHausOdioArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausOdioArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script + for HexenHausOdioArchive<'b, T> +{ fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -252,7 +254,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausOdioArchive< Ok(Box::new(self.entries.iter().map(|entry| Ok(entry.offset)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow!( "Index out of bounds: {} (total files: {})", diff --git a/src/scripts/hexen_haus/archive/wag.rs b/src/scripts/hexen_haus/archive/wag.rs index 40c3e25..0c5d53b 100644 --- a/src/scripts/hexen_haus/archive/wag.rs +++ b/src/scripts/hexen_haus/archive/wag.rs @@ -336,7 +336,9 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> HexenHausWagArchive<'b, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausWagArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script + for HexenHausWagArchive<'b, T> +{ fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -361,7 +363,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for HexenHausWagArchive<' Ok(Box::new(self.entries.iter().map(|entry| Ok(entry.offset)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow!( "Index out of bounds: {} (total files: {})", diff --git a/src/scripts/kirikiri/archive/xp3/mod.rs b/src/scripts/kirikiri/archive/xp3/mod.rs index 9f10333..28d70b8 100644 --- a/src/scripts/kirikiri/archive/xp3/mod.rs +++ b/src/scripts/kirikiri/archive/xp3/mod.rs @@ -226,7 +226,7 @@ impl<'b> Script for Xp3Archive<'b> { )) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { let index = self .archive .entries @@ -414,7 +414,7 @@ impl<'b> ArchiveContent for Entry<'b> { &self.index.name } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(self)) } @@ -758,7 +758,7 @@ impl<'b> ArchiveContent for SimpleCrypt<'b> { &self.index.name } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(self)) } } @@ -812,7 +812,7 @@ impl<'a> Read for MdfEntry<'a> { #[derive(Debug)] struct CustomFilterEntry<'a> { - inner: PrefixStream>, + inner: PrefixStream>, index: archive::Xp3Entry, script_type: Option, } @@ -835,7 +835,7 @@ impl<'a> ArchiveContent for CustomFilterEntry<'a> { #[derive(Debug)] struct CustomFilterWithSeekEntry<'a> { - inner: Box, + inner: Box, index: archive::Xp3Entry, script_type: Option, } @@ -869,7 +869,7 @@ impl<'b> ArchiveContent for CustomFilterWithSeekEntry<'b> { self.script_type.as_ref() } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(self)) } } diff --git a/src/scripts/musica/archive/paz.rs b/src/scripts/musica/archive/paz.rs index 4497275..e7eb808 100644 --- a/src/scripts/musica/archive/paz.rs +++ b/src/scripts/musica/archive/paz.rs @@ -414,7 +414,7 @@ impl<'b> Script for PazArc<'b> { Ok(Box::new(self.entries.iter().map(|entry| Ok(entry.offset)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.entries.len() { return Err(anyhow::anyhow!("Index out of bounds")); } diff --git a/src/scripts/qlie/archive/pack/encryption.rs b/src/scripts/qlie/archive/pack/encryption.rs index 97154c5..832b34a 100644 --- a/src/scripts/qlie/archive/pack/encryption.rs +++ b/src/scripts/qlie/archive/pack/encryption.rs @@ -30,9 +30,9 @@ pub trait Encryption: std::fmt::Debug { fn decrypt_name(&self, name: &mut [u8], hash: i32, encoding: Encoding) -> Result; fn decrypt_entry<'a>( &self, - stream: Box, + stream: Box, entry: &QlieEntry, - ) -> Result>; + ) -> Result>; fn index_has_hash(&self) -> bool { true } @@ -56,7 +56,9 @@ pub fn create_encryption( } } -pub fn decompress<'a>(data: Box) -> Result> { +pub fn decompress<'a>( + data: Box, +) -> Result> { Ok(Box::new(Decompressor::new(data)?)) } @@ -223,9 +225,9 @@ impl Encryption for Encryption31 { } fn decrypt_entry<'a>( &self, - stream: Box, + stream: Box, entry: &QlieEntry, - ) -> Result> { + ) -> Result> { match entry.is_encrypted { // No encryption 0 => Ok(Box::new(stream)), @@ -317,7 +319,7 @@ impl Hasher for Encryption31Hasher { #[derive(Debug)] struct Encryption31DecryptV1<'a> { - stream: Box, + stream: Box, table: MemReader, v4: u32, v6: u64, @@ -325,7 +327,7 @@ struct Encryption31DecryptV1<'a> { impl<'a> Encryption31DecryptV1<'a> { pub fn new( - stream: Box, + stream: Box, size: u32, name: String, key: u32, @@ -437,7 +439,7 @@ impl Write for Encryption31EncryptV1 { #[derive(Debug)] struct Encryption31DecryptV2<'a> { - stream: Box, + stream: Box, table: MemReader, v4: u32, v6: u64, @@ -446,7 +448,7 @@ struct Encryption31DecryptV2<'a> { impl<'a> Encryption31DecryptV2<'a> { pub fn new( - stream: Box, + stream: Box, size: u32, name: String, key: u32, @@ -574,7 +576,7 @@ impl Write for Encryption31EncryptV2 { #[derive(Debug)] pub struct Decompressor<'a> { - stream: Box, + stream: Box, is_16bit: bool, temp: Vec, buf: Vec, @@ -582,7 +584,7 @@ pub struct Decompressor<'a> { } impl<'a> Decompressor<'a> { - pub fn new(mut stream: Box) -> Result { + pub fn new(mut stream: Box) -> Result { let sign = stream.read_u32()?; if sign != 0xFF435031 { return Err(anyhow::anyhow!("Invalid compression signature")); @@ -1061,9 +1063,9 @@ impl Encryption for Encryption30 { fn decrypt_entry<'a>( &self, - stream: Box, + stream: Box, entry: &QlieEntry, - ) -> Result> { + ) -> Result> { if entry.is_encrypted == 0 { return Ok(Box::new(stream)); } @@ -1144,13 +1146,17 @@ impl Hasher for Encryption30Hasher { #[derive(Debug)] pub struct Decrypter<'a> { - stream: Box, + stream: Box, v5: u64, v9: u64, } impl<'a> Decrypter<'a> { - pub fn new(stream: Box, key: u32, length: u32) -> AlignedReader<8, Self> { + pub fn new( + stream: Box, + key: u32, + length: u32, + ) -> AlignedReader<8, Self> { const C1: u64 = 0xA73C5F9D; const C3: u64 = 0xFEC9753E; const V5_INIT: u64 = mmx_punpckldq2(C1); @@ -1182,7 +1188,7 @@ impl<'a> Read for Decrypter<'a> { #[derive(Debug)] struct Encryption30Decrypt<'a> { - stream: Box, + stream: Box, table: [u64; 0x10], hash64: u64, t: usize, @@ -1190,7 +1196,7 @@ struct Encryption30Decrypt<'a> { impl<'a> Encryption30Decrypt<'a> { pub fn new<'b>( - stream: Box, + stream: Box, raw_name: &'b [u8], common_key: &'b [u8], size: u32, @@ -1275,9 +1281,9 @@ impl Encryption for Encryption10 { fn decrypt_entry<'a>( &self, - stream: Box, + stream: Box, entry: &QlieEntry, - ) -> Result> { + ) -> Result> { if entry.is_encrypted == 0 { return Ok(Box::new(stream)); } @@ -1320,9 +1326,9 @@ impl Encryption for Encryption20 { fn decrypt_entry<'a>( &self, - stream: Box, + stream: Box, entry: &QlieEntry, - ) -> Result> { + ) -> Result> { if entry.is_encrypted == 0 { return Ok(Box::new(stream)); } @@ -1336,13 +1342,13 @@ impl Encryption for Encryption20 { #[derive(Debug)] struct Encryption10Decrypt<'a> { - stream: Box, + stream: Box, v5: u64, v9: u64, } impl<'a> Encryption10Decrypt<'a> { - pub fn new(stream: Box, key: u32) -> AlignedReader<8, Self> { + pub fn new(stream: Box, key: u32) -> AlignedReader<8, Self> { const C1: u64 = 0xA73C5F9D; const C3: u64 = 0xFEC9753E; const V5_INIT: u64 = mmx_punpckldq2(C1); diff --git a/src/scripts/qlie/archive/pack/mod.rs b/src/scripts/qlie/archive/pack/mod.rs index e4e0bf3..824eafa 100644 --- a/src/scripts/qlie/archive/pack/mod.rs +++ b/src/scripts/qlie/archive/pack/mod.rs @@ -320,7 +320,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for QliePac Ok(Box::new(self.entries.iter().map(|e| Ok(e.name.clone())))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { let mut entry = self .entries .get(index) diff --git a/src/scripts/softpal/arc/pac.rs b/src/scripts/softpal/arc/pac.rs index 2763a30..1e59167 100644 --- a/src/scripts/softpal/arc/pac.rs +++ b/src/scripts/softpal/arc/pac.rs @@ -144,7 +144,7 @@ pub struct SoftpalPacArchive<'a, T: Read + Seek + std::fmt::Debug + 'a> { _mark: std::marker::PhantomData<&'a ()>, } -impl<'a, T: Read + Seek + std::fmt::Debug + 'a> SoftpalPacArchive<'a, T> { +impl<'a, T: Read + Seek + std::fmt::Debug + Send + Sync + 'a> SoftpalPacArchive<'a, T> { fn new( mut reader: T, archive_encoding: Encoding, @@ -237,7 +237,7 @@ impl<'a, T: Read + Seek + std::fmt::Debug + 'a> SoftpalPacArchive<'a, T> { } } -impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for SoftpalPacArchive<'b, T> { +impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for SoftpalPacArchive<'b, T> { fn default_output_script_type(&self) -> OutputScriptType { OutputScriptType::Json } @@ -264,7 +264,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for SoftpalPacArchive<'b, )) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { let entry = self .entries .get(index) diff --git a/src/scripts/yaneurao/itufuru/archive.rs b/src/scripts/yaneurao/itufuru/archive.rs index e028673..4527656 100644 --- a/src/scripts/yaneurao/itufuru/archive.rs +++ b/src/scripts/yaneurao/itufuru/archive.rs @@ -163,7 +163,7 @@ impl ArchiveContent for Entry { Ok(self.data.data.clone()) } - fn to_data<'a>(&'a mut self) -> Result> { + fn to_data<'a>(&'a mut self) -> Result> { Ok(Box::new(&mut self.data)) } } @@ -250,7 +250,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + 'b> Script for ItufuruArchive<'b, T> Ok(Box::new(self.files.iter().map(|s| Ok(s.offset as u64)))) } - fn open_file<'a>(&'a self, index: usize) -> Result> { + fn open_file<'a>(&'a self, index: usize) -> Result> { if index >= self.files.len() { return Err(anyhow::anyhow!( "Index out of bounds: {} (max: {})",