From ba3e75c3fb374599fd47fed559a82d52d1b649a6 Mon Sep 17 00:00:00 2001 From: Raine Date: Sat, 14 Oct 2023 22:39:40 +0200 Subject: [PATCH] fix: pkg interpreting --- pkgfile/src/lib.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pkgfile/src/lib.rs b/pkgfile/src/lib.rs index c3c056b..bc26f99 100644 --- a/pkgfile/src/lib.rs +++ b/pkgfile/src/lib.rs @@ -9,28 +9,22 @@ impl TryFrom> for PKGFile { fn try_from(value: Vec) -> Result { match value[0] { 1 => { - let header: Vec = value[..3] - .iter() - .map(|v| u32::from(*v)) - .collect(); + let header: Vec = value[..3].iter().map(|v| u32::from(*v)).collect(); let manifest_size: u32 = (header[1] << 8) | header[2]; if manifest_size > value.len() as u32 { return Err(()); } Ok(PKGFile { manifest: match String::from_utf8( - value[ - 3..(manifest_size as usize + 3) - ].to_vec() - ) - { + value[3..(manifest_size as usize + 3)].to_vec(), + ) { Ok(s) => s, - _ => return Err(()) + _ => return Err(()), }, data: value[(manifest_size as usize + 3)..].to_vec(), }) } - _ => Err(()) + _ => Err(()), } } } @@ -45,4 +39,4 @@ impl Into> for PKGFile { bytes.extend(self.data); bytes } -} \ No newline at end of file +}