dharitri_vm_executor/new_traits/
breakpoint_value_new.rs

1use crate::BreakpointValueLegacy;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum BreakpointValue {
5    /// Lack of a breakpoint
6    None = 0,
7
8    /// Stopping due to gas being exhausted.
9    OutOfGas = 1,
10
11    /// Stopping due to over-allocation of WASM memory.
12    MemoryLimit = 2,
13}
14
15impl BreakpointValue {
16    pub fn as_u64(self) -> u64 {
17        self as u64
18    }
19
20    pub fn to_legacy(self) -> BreakpointValueLegacy {
21        match self {
22            BreakpointValue::None => BreakpointValueLegacy::None,
23            BreakpointValue::OutOfGas => BreakpointValueLegacy::OutOfGas,
24            BreakpointValue::MemoryLimit => BreakpointValueLegacy::MemoryLimit,
25        }
26    }
27}
28
29pub struct UnknownBreakpointValueError;
30
31impl TryFrom<u64> for BreakpointValue {
32    type Error = UnknownBreakpointValueError;
33
34    fn try_from(value: u64) -> Result<Self, Self::Error> {
35        match value {
36            0 => Ok(BreakpointValue::None),
37            4 => Ok(BreakpointValue::OutOfGas),
38            5 => Ok(BreakpointValue::MemoryLimit),
39            _ => Err(UnknownBreakpointValueError),
40        }
41    }
42}