revm_rwasm_bytecode/
decode_errors.rs

1use crate::{eip7702::Eip7702DecodeError, ownable_account::OwnableAccountDecodeError};
2use core::fmt::Debug;
3use std::fmt;
4
5/// Bytecode decode errors
6#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub enum BytecodeDecodeError {
9    /// EIP-7702 decode error
10    Eip7702(Eip7702DecodeError),
11    /// Metadata decode error
12    OwnableAccount(OwnableAccountDecodeError),
13}
14
15impl From<Eip7702DecodeError> for BytecodeDecodeError {
16    fn from(error: Eip7702DecodeError) -> Self {
17        Self::Eip7702(error)
18    }
19}
20
21impl From<OwnableAccountDecodeError> for BytecodeDecodeError {
22    fn from(error: OwnableAccountDecodeError) -> Self {
23        Self::OwnableAccount(error)
24    }
25}
26
27impl core::error::Error for BytecodeDecodeError {}
28
29impl fmt::Display for BytecodeDecodeError {
30    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31        match self {
32            Self::Eip7702(e) => fmt::Display::fmt(e, f),
33            Self::OwnableAccount(e) => fmt::Display::fmt(e, f),
34        }
35    }
36}