diff --git a/brro-compressor/src/compressor/constant.rs b/brro-compressor/src/compressor/constant.rs index 19a6274..62e1f71 100644 --- a/brro-compressor/src/compressor/constant.rs +++ b/brro-compressor/src/compressor/constant.rs @@ -87,10 +87,8 @@ impl Constant { /// Receives a data stream and generates a Constant pub fn decompress(data: &[u8]) -> Self { let config = BinConfig::get(); - match bincode::decode_from_slice(data, config) { - Ok((constant, _)) => constant, - Err(e) => panic!("{e}"), - } + let (ct, _) = bincode::decode_from_slice(data, config).unwrap(); + ct } /// This function transforms the structure into a Binary stream diff --git a/brro-compressor/src/compressor/fft.rs b/brro-compressor/src/compressor/fft.rs index 7a311bd..f522bbd 100644 --- a/brro-compressor/src/compressor/fft.rs +++ b/brro-compressor/src/compressor/fft.rs @@ -176,10 +176,8 @@ impl FFT { /// Decompresses data pub fn decompress(data: &[u8]) -> Self { let config = BinConfig::get(); - match bincode::decode_from_slice(data, config) { - Ok((fft, _)) => fft, - Err(e) => panic!("{e}") - } + let (fft, _) = bincode::decode_from_slice(data, config).unwrap(); + fft } pub fn to_bytes(self) -> Vec { diff --git a/brro-compressor/src/compressor/mod.rs b/brro-compressor/src/compressor/mod.rs index c94cd72..0970e62 100644 --- a/brro-compressor/src/compressor/mod.rs +++ b/brro-compressor/src/compressor/mod.rs @@ -25,7 +25,7 @@ impl Compressor { Compressor::Noop => noop(data), Compressor::FFT => fft(data, 8, 0.0, 10.0), // TODO: Remove the placeholders Compressor::Constant => constant(data), - _ => noop(data), + _ => todo!(), } } } diff --git a/brro-compressor/src/compressor/noop.rs b/brro-compressor/src/compressor/noop.rs index 5f05289..d7a4e49 100644 --- a/brro-compressor/src/compressor/noop.rs +++ b/brro-compressor/src/compressor/noop.rs @@ -38,10 +38,8 @@ impl Noop { /// Receives a data stream and generates a Noop pub fn decompress(data: &[u8]) -> Self { let config = BinConfig::get(); - match bincode::decode_from_slice(data, config) { - Ok((constant, _)) => constant, - Err(e) => panic!("{e}"), - } + let (noop, _) = bincode::decode_from_slice(data, config).unwrap(); + noop } /// This function transforms the structure in a Binary stream to be appended to the frame diff --git a/brro-compressor/src/data.rs b/brro-compressor/src/data.rs index bba68c8..22f1690 100644 --- a/brro-compressor/src/data.rs +++ b/brro-compressor/src/data.rs @@ -45,10 +45,8 @@ impl CompressedStream { /// Gets a binary stream and generates a Compressed Stream pub fn from_bytes(data: &[u8]) -> Self { let config = BinConfig::get(); - match bincode::decode_from_slice(data, config) { - Ok((compressed_stream, _)) => compressed_stream, - Err(e) => panic!("{e}") - } + let (compressed_stream, _) = bincode::decode_from_slice(data, config).unwrap(); + compressed_stream } } diff --git a/brro-compressor/src/utils/reader.rs b/brro-compressor/src/utils/reader.rs index cfd3c8d..0567a71 100644 --- a/brro-compressor/src/utils/reader.rs +++ b/brro-compressor/src/utils/reader.rs @@ -43,10 +43,7 @@ pub struct Files { /// Read a file by chunks and processes the chunks pub fn process_by_chunk(file_path: &Path) -> Result<(), std::io::Error> { - let mut file = match std::fs::File::open(file_path) { - Ok(f) => f, - Err(e) => panic!("{}", e) - }; + let mut file = std::fs::File::open(file_path)?; let mut list_of_chunks = Vec::new(); // 64KB at a time, assuming 64Bit samples, ~1024 samples.