diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-05-22 15:56:52 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-05-22 15:56:52 +0200 |
commit | 2b1165a8cfffe93519dc6ccfd3434b6db33ea101 (patch) | |
tree | d69fca84e9f498e76955173835e0d8a75a11d0f9 /src | |
parent | 6438f2ff906ca8b97d1d43f5ccd3c22fb5a4cad9 (diff) | |
download | elfload-2b1165a8cfffe93519dc6ccfd3434b6db33ea101.tar.gz elfload-2b1165a8cfffe93519dc6ccfd3434b6db33ea101.zip |
remove read_u8 and derive FromEndian for u8
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -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<u8> { - if let Some(byte) = self.bytes.get(self.pos) { - self.bump(1); - Ok(*byte) - } else { - Err(Error::OutOfBytes) - } - } - fn read<E: FromEndian>(&mut self, en: Endian) -> Result<E> { 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::<u8>(Endian::Little).map(Bit::try_from)??; + let en = r.read::<u8>(Endian::Little).map(Endian::try_from)??; // Consume rest of e_ident. r.bump(10); |