From 447dd8c6f1a95c21e991944810075fc9caf62764 Mon Sep 17 00:00:00 2001 From: liquidev Date: Sat, 24 Aug 2024 16:13:56 +0200 Subject: [PATCH] remove unused rkgk::binary module --- crates/rkgk/src/binary.rs | 51 --------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 crates/rkgk/src/binary.rs diff --git a/crates/rkgk/src/binary.rs b/crates/rkgk/src/binary.rs deleted file mode 100644 index 532b004..0000000 --- a/crates/rkgk/src/binary.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::{error::Error, fmt}; - -pub struct Reader<'a> { - slice: &'a [u8], -} - -impl<'a> Reader<'a> { - pub fn new(slice: &'a [u8]) -> Self { - Self { slice } - } - - pub fn read_u8(&mut self) -> Result { - if !self.slice.is_empty() { - Ok(self.slice[0]) - } else { - Err(OutOfData) - } - } - - pub fn read_u16(&mut self) -> Result { - if self.slice.len() >= 2 { - Ok(u16::from_le_bytes([self.slice[0], self.slice[1]])) - } else { - Err(OutOfData) - } - } - - pub fn read_u32(&mut self) -> Result { - if self.slice.len() >= 4 { - Ok(u32::from_le_bytes([ - self.slice[0], - self.slice[1], - self.slice[2], - self.slice[3], - ])) - } else { - Err(OutOfData) - } - } -} - -#[derive(Debug, Clone, Copy)] -pub struct OutOfData; - -impl fmt::Display for OutOfData { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("reader ran out of data") - } -} - -impl Error for OutOfData {}