diff --git a/src/scripts/artemis/archive/pf2.rs b/src/scripts/artemis/archive/pf2.rs index b495b17..c969f1f 100644 --- a/src/scripts/artemis/archive/pf2.rs +++ b/src/scripts/artemis/archive/pf2.rs @@ -242,14 +242,15 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for Artemis } } -struct Pf2Entry { +#[derive(Debug)] +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 } @@ -257,9 +258,13 @@ impl ArchiveContent for Pf2Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -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 +284,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 6e45956..a6a5885 100644 --- a/src/scripts/artemis/archive/pfs.rs +++ b/src/scripts/artemis/archive/pfs.rs @@ -257,7 +257,8 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script for Artemis } } -struct Entry { +#[derive(Debug)] +struct Entry { header: PfsEntryHeader, reader: Arc>, pos: u64, @@ -265,7 +266,7 @@ struct Entry { xor_key: Option<[u8; 20]>, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -273,9 +274,13 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -impl Read for Entry { +impl Read for Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -300,7 +305,7 @@ impl Read for Entry { } } -impl Seek for Entry { +impl Seek for Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset, diff --git a/src/scripts/bgi/archive/v1.rs b/src/scripts/bgi/archive/v1.rs index 9407756..0530cac 100644 --- a/src/scripts/bgi/archive/v1.rs +++ b/src/scripts/bgi/archive/v1.rs @@ -138,7 +138,8 @@ struct BgiFileHeader { _padding: Vec, } -struct Entry { +#[derive(Debug)] +struct Entry { header: BgiFileHeader, reader: Arc>, pos: usize, @@ -146,7 +147,7 @@ struct Entry { script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.filename } @@ -154,9 +155,13 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -impl Read for Entry { +impl Read for Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -177,7 +182,7 @@ impl Read for Entry { } } -impl Seek for Entry { +impl Seek for Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset as usize, diff --git a/src/scripts/bgi/archive/v2.rs b/src/scripts/bgi/archive/v2.rs index d96c331..7c8be16 100644 --- a/src/scripts/bgi/archive/v2.rs +++ b/src/scripts/bgi/archive/v2.rs @@ -140,7 +140,8 @@ struct BgiFileHeader { _padding: Vec, } -struct Entry { +#[derive(Debug)] +struct Entry { header: BgiFileHeader, reader: Arc>, pos: usize, @@ -148,7 +149,7 @@ struct Entry { script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.filename } @@ -156,9 +157,13 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -impl Read for Entry { +impl Read for Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -179,7 +184,7 @@ impl Read for Entry { } } -impl Seek for Entry { +impl Seek for Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset as usize, diff --git a/src/scripts/cat_system/archive/int.rs b/src/scripts/cat_system/archive/int.rs index 2cb1bb7..333c94f 100644 --- a/src/scripts/cat_system/archive/int.rs +++ b/src/scripts/cat_system/archive/int.rs @@ -136,14 +136,15 @@ struct CSIntFileHeader { size: u32, } -struct Entry { +#[derive(Debug)] +struct Entry { header: CSIntFileHeader, reader: Arc>, pos: usize, script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -151,9 +152,13 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -impl Read for Entry { +impl Read for Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -172,7 +177,7 @@ impl Read for Entry { } } -impl Seek for Entry { +impl Seek for Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset as usize, diff --git a/src/scripts/circus/archive/crm.rs b/src/scripts/circus/archive/crm.rs index 422f464..f261b6a 100644 --- a/src/scripts/circus/archive/crm.rs +++ b/src/scripts/circus/archive/crm.rs @@ -104,14 +104,15 @@ struct CrmFileHeader { name: String, } -struct Entry { +#[derive(Debug)] +struct Entry { header: CrmFileHeader, reader: Arc>, pos: usize, script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -119,9 +120,13 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } -impl Read for Entry { +impl Read for Entry { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let mut reader = self.reader.lock().map_err(|e| { std::io::Error::new( @@ -140,7 +145,7 @@ impl Read for Entry { } } -impl Seek for Entry { +impl Seek for Entry { fn seek(&mut self, pos: SeekFrom) -> std::io::Result { let new_pos = match pos { SeekFrom::Start(offset) => offset as usize, diff --git a/src/scripts/circus/archive/dat.rs b/src/scripts/circus/archive/dat.rs index ed5f14a..e3d3e31 100644 --- a/src/scripts/circus/archive/dat.rs +++ b/src/scripts/circus/archive/dat.rs @@ -100,6 +100,7 @@ struct DatFileHeader { size: u32, } +#[derive(Debug)] struct Entry { header: DatFileHeader, reader: Arc>, @@ -107,7 +108,7 @@ struct Entry { script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -115,6 +116,10 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for Entry { diff --git a/src/scripts/circus/archive/pck.rs b/src/scripts/circus/archive/pck.rs index 3c21de2..6ee5713 100644 --- a/src/scripts/circus/archive/pck.rs +++ b/src/scripts/circus/archive/pck.rs @@ -119,6 +119,7 @@ struct PckFileHeader { size: u32, } +#[derive(Debug)] struct Entry { header: PckFileHeader, reader: Arc>, @@ -126,7 +127,7 @@ struct Entry { script_type: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -134,6 +135,10 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for Entry { diff --git a/src/scripts/ex_hibit/arc/grp.rs b/src/scripts/ex_hibit/arc/grp.rs index 5184e6a..4f9a6d7 100644 --- a/src/scripts/ex_hibit/arc/grp.rs +++ b/src/scripts/ex_hibit/arc/grp.rs @@ -197,6 +197,7 @@ impl<'b, T: Read + Seek + Debug + Send + Sync + 'b> Script for ExHibitGrpArchive } } +#[derive(Debug)] struct GrpEntry { info: GrpFileEntry, reader: Arc>, @@ -217,10 +218,13 @@ impl GrpEntry { } } -impl ArchiveContent for GrpEntry { +impl ArchiveContent for GrpEntry { fn name(&self) -> &str { &self.info.name } + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for GrpEntry { diff --git a/src/scripts/hexen_haus/archive/arcc.rs b/src/scripts/hexen_haus/archive/arcc.rs index 0197bd3..d731b24 100644 --- a/src/scripts/hexen_haus/archive/arcc.rs +++ b/src/scripts/hexen_haus/archive/arcc.rs @@ -264,6 +264,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script } } +#[derive(Debug)] struct Entry { header: HexenHausArccEntry, reader: Arc>, @@ -271,7 +272,7 @@ struct Entry { typ: Option, } -impl ArchiveContent for Entry { +impl ArchiveContent for Entry { fn name(&self) -> &str { &self.header.name } @@ -279,6 +280,10 @@ impl ArchiveContent for Entry { fn script_type(&self) -> Option<&ScriptType> { self.typ.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for Entry { diff --git a/src/scripts/hexen_haus/archive/odio.rs b/src/scripts/hexen_haus/archive/odio.rs index 94b2ecd..0a2a7e1 100644 --- a/src/scripts/hexen_haus/archive/odio.rs +++ b/src/scripts/hexen_haus/archive/odio.rs @@ -302,6 +302,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script } } +#[derive(Debug)] struct OdioEntry { name: String, reader: Arc>, @@ -311,10 +312,14 @@ struct OdioEntry { decrypt: bool, } -impl ArchiveContent for OdioEntry { +impl ArchiveContent for OdioEntry { fn name(&self) -> &str { &self.name } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for OdioEntry { diff --git a/src/scripts/hexen_haus/archive/wag.rs b/src/scripts/hexen_haus/archive/wag.rs index 0c5d53b..f7b3ad2 100644 --- a/src/scripts/hexen_haus/archive/wag.rs +++ b/src/scripts/hexen_haus/archive/wag.rs @@ -384,6 +384,7 @@ impl<'b, T: Read + Seek + std::fmt::Debug + Send + Sync + 'b> Script } } +#[derive(Debug)] struct WagEntry { header: HexenHausWagEntry, reader: Arc>, @@ -391,7 +392,7 @@ struct WagEntry { typ: Option, } -impl ArchiveContent for WagEntry { +impl ArchiveContent for WagEntry { fn name(&self) -> &str { &self.header.name } @@ -399,6 +400,10 @@ impl ArchiveContent for WagEntry { fn script_type(&self) -> Option<&ScriptType> { self.typ.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for WagEntry { diff --git a/src/scripts/softpal/arc/pac.rs b/src/scripts/softpal/arc/pac.rs index 1e59167..858cd4b 100644 --- a/src/scripts/softpal/arc/pac.rs +++ b/src/scripts/softpal/arc/pac.rs @@ -338,6 +338,14 @@ impl ArchiveContent for MemEntry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn data(&mut self) -> Result> { + Ok(self.data.clone()) + } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(MemReaderRef::new(&self.data))) + } } impl Read for MemEntry { @@ -402,7 +410,7 @@ impl PacEntry { } } -impl ArchiveContent for PacEntry { +impl ArchiveContent for PacEntry { fn name(&self) -> &str { &self.header.name } @@ -410,6 +418,10 @@ impl ArchiveContent for PacEntry { fn script_type(&self) -> Option<&ScriptType> { self.script_type.as_ref() } + + fn to_data<'a>(&'a mut self) -> Result> { + Ok(Box::new(self)) + } } impl Read for PacEntry {