Fix formatting and minor restructuring

Fixed formatting using cargo fmt.
Change some parser structure to reduce code deduplication
This commit is contained in:
Lol3rrr
2024-09-22 20:31:38 +02:00
parent c1e85d77dc
commit 67d33f64c0
6 changed files with 53 additions and 90 deletions

View File

@@ -39,7 +39,10 @@ impl<'b> Frame<'b> {
Some(self.inner.as_ref())
}
pub fn decompress_with_buf<'s, 'buf>(&'s self, buf: &'b mut Vec<u8>) -> Result<&'buf [u8], ()> where 's: 'buf {
pub fn decompress_with_buf<'s, 'buf>(&'s self, buf: &'b mut Vec<u8>) -> Result<&'buf [u8], ()>
where
's: 'buf,
{
if !self.compressed {
return Ok(&self.inner);
}
@@ -50,10 +53,12 @@ impl<'b> Frame<'b> {
})?;
buf.resize(uncompressed_len, 0);
snap::raw::Decoder::new().decompress(&self.inner, buf.as_mut_slice()).map_err(|e| {
println!("Decompressing");
()
})?;
snap::raw::Decoder::new()
.decompress(&self.inner, buf.as_mut_slice())
.map_err(|e| {
println!("Decompressing");
()
})?;
Ok(buf.as_slice())
}