revm_bytecode/legacy/
raw.rs

1use super::LegacyAnalyzedBytecode;
2use core::ops::Deref;
3use primitives::Bytes;
4
5/// Used only as intermediate representation for legacy bytecode.
6///
7/// See [`LegacyAnalyzedBytecode`] for the main structure that is used in Revm.
8#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct LegacyRawBytecode(pub Bytes);
11
12impl LegacyRawBytecode {
13    /// Analyzes the bytecode, instantiating a [`LegacyAnalyzedBytecode`].
14    pub fn into_analyzed(self) -> LegacyAnalyzedBytecode {
15        LegacyAnalyzedBytecode::analyze(self.0)
16    }
17}
18
19impl From<Bytes> for LegacyRawBytecode {
20    fn from(bytes: Bytes) -> Self {
21        Self(bytes)
22    }
23}
24
25impl<const N: usize> From<[u8; N]> for LegacyRawBytecode {
26    fn from(bytes: [u8; N]) -> Self {
27        Self(bytes.into())
28    }
29}
30
31impl Deref for LegacyRawBytecode {
32    type Target = Bytes;
33
34    fn deref(&self) -> &Self::Target {
35        &self.0
36    }
37}