pub struct Decrypter<'a> { /* private fields */ }
Expand description
A struct responsible for decrypting and extracting files from encrypted game archives.
Implementations§
Source§impl<'a> Decrypter<'a>
impl<'a> Decrypter<'a>
Sourcepub fn decrypt(
&mut self,
data: &'a [u8],
) -> Result<Vec<DecryptedFile>, ExtractError>
pub fn decrypt( &mut self, data: &'a [u8], ) -> Result<Vec<DecryptedFile>, ExtractError>
Returns Vec
of decrypted files.
§Parameters
data
: The content of the archive file.
§Returns
Ok(Vec<DecryptedFile>)
if files were successfully decrypted.Err(ExtractError::InvalidHeader)
for invalid header.Err(ExtractError::InvalidEngine)
for invalid header engine type byte.
§Example
use rpgmad_lib::Decrypter;
use std::path::PathBuf;
let data: Vec<u8> = std::fs::read("C:/Game/Game.rgss3a").unwrap();
let decrypted_files = Decrypter::new().decrypt(&data).unwrap();
for file in decrypted_files {
let path = String::from_utf8_lossy(&file.path);
let output_path = PathBuf::from("C:/Game").join(path.as_ref());
if let Some(parent) = output_path.parent() {
std::fs::create_dir_all(parent).unwrap();
}
std::fs::write(output_path, file.content).unwrap();
}
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Decrypter<'a>
impl<'a> RefUnwindSafe for Decrypter<'a>
impl<'a> Send for Decrypter<'a>
impl<'a> Sync for Decrypter<'a>
impl<'a> Unpin for Decrypter<'a>
impl<'a> UnwindSafe for Decrypter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more