Reverter errors from taking a &'static str to String

This commit is contained in:
CosminPerRam 2022-11-25 18:42:10 +02:00
parent dc0926bab7
commit 7b44c5f7eb
10 changed files with 59 additions and 59 deletions

View file

@ -117,18 +117,18 @@ impl SplitPacket {
fn get_payload(&self) -> GDResult<Vec<u8>> {
if self.compressed {
let mut decoder = Decoder::new();
decoder.write(&self.payload).map_err(|e| GDError::Decompress(e.to_string().as_str()))?;
decoder.write(&self.payload).map_err(|e| GDError::Decompress(e.to_string()))?;
let decompressed_size = self.decompressed_size.unwrap() as usize;
let mut decompressed_payload = Vec::with_capacity(decompressed_size);
decoder.read(&mut decompressed_payload).map_err(|e| GDError::Decompress(e.to_string().as_str()))?;
decoder.read(&mut decompressed_payload).map_err(|e| GDError::Decompress(e.to_string()))?;
if decompressed_payload.len() != decompressed_size {
Err(GDError::Decompress("The decompressed payload size doesn't match the expected one."))
Err(GDError::Decompress("The decompressed payload size doesn't match the expected one.".to_string()))
}
else if crc32fast::hash(&decompressed_payload) != self.uncompressed_crc32.unwrap() {
Err(GDError::Decompress("The decompressed crc32 hash does not match the expected one."))
Err(GDError::Decompress("The decompressed crc32 hash does not match the expected one.".to_string()))
}
else {
Ok(decompressed_payload)
@ -420,7 +420,7 @@ fn get_response(address: &str, port: u16, app: App, gather_settings: GatheringSe
if let App::Source(x) = &app {
if let Some(appid) = x {
if *appid != info.appid {
return Err(GDError::BadGame(format!("Expected {}, found {} instead!", *appid, info.appid).as_str()));
return Err(GDError::BadGame(format!("Expected {}, found {} instead!", *appid, info.appid)));
}
}
}