aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-05-22 15:56:52 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-05-22 15:56:52 +0200
commit2b1165a8cfffe93519dc6ccfd3434b6db33ea101 (patch)
treed69fca84e9f498e76955173835e0d8a75a11d0f9 /src
parent6438f2ff906ca8b97d1d43f5ccd3c22fb5a4cad9 (diff)
downloadelfload-2b1165a8cfffe93519dc6ccfd3434b6db33ea101.tar.gz
elfload-2b1165a8cfffe93519dc6ccfd3434b6db33ea101.zip
remove read_u8 and derive FromEndian for u8
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 3 insertions, 11 deletions
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<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);