From 2b1165a8cfffe93519dc6ccfd3434b6db33ea101 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 22 May 2022 15:56:52 +0200 Subject: remove read_u8 and derive FromEndian for u8 --- src/lib.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 301944c..9d79e73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,7 @@ macro_rules! impl_from_endian { }; } +impl_from_endian!(u8); impl_from_endian!(u16); impl_from_endian!(u32); impl_from_endian!(u64); @@ -136,15 +137,6 @@ impl<'bytes> ElfReader<'bytes> { } } - fn read_u8(&mut self) -> Result { - if let Some(byte) = self.bytes.get(self.pos) { - self.bump(1); - Ok(*byte) - } else { - Err(Error::OutOfBytes) - } - } - fn read(&mut self, en: Endian) -> Result { let bytes = self.bytes.get(self.pos..).ok_or(Error::OutOfBytes)?; @@ -220,8 +212,8 @@ impl<'bytes, const N: usize> Elf<'bytes, N> { return Err(Error::WrongElfMagic); } - let bit = r.read_u8().map(Bit::try_from)??; - let en = r.read_u8().map(Endian::try_from)??; + let bit = r.read::(Endian::Little).map(Bit::try_from)??; + let en = r.read::(Endian::Little).map(Endian::try_from)??; // Consume rest of e_ident. r.bump(10); -- cgit v1.2.3