revm_bytecode/eof/
decode_helpers.rs1use super::EofDecodeError;
2
3#[inline]
8pub(crate) fn consume_u8(input: &[u8]) -> Result<(&[u8], u8), EofDecodeError> {
9 if input.is_empty() {
10 return Err(EofDecodeError::MissingInput);
11 }
12 Ok((&input[1..], input[0]))
13}
14
15#[inline]
19pub(crate) fn consume_u16(input: &[u8]) -> Result<(&[u8], u16), EofDecodeError> {
20 if input.len() < 2 {
21 return Err(EofDecodeError::MissingInput);
22 }
23 let (int_bytes, rest) = input.split_at(2);
24 Ok((rest, u16::from_be_bytes([int_bytes[0], int_bytes[1]])))
25}