dharitri_vm_executor/
breakpoint_value.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum BreakpointValue {
3    /// Lack of a breakpoint
4    None = 0,
5
6    /// Failure indicated by the high-level VM (in the VMHooks).
7    ExecutionFailed = 1,
8
9    /// Stopping execution due to an async call.
10    AsyncCall = 2,
11
12    /// Stopping due to an error signalled by the contract.
13    SignalError = 3,
14
15    /// Stopping due to gas being exhausted.
16    OutOfGas = 4,
17
18    /// Stopping due to over-allocation of WASM memory.
19    MemoryLimit = 5,
20}
21
22impl BreakpointValue {
23    pub fn as_u64(self) -> u64 {
24        self as u64
25    }
26}
27
28impl TryFrom<u64> for BreakpointValue {
29    type Error = String;
30
31    fn try_from(value: u64) -> Result<Self, Self::Error> {
32        match value {
33            0 => Ok(BreakpointValue::None),
34            1 => Ok(BreakpointValue::ExecutionFailed),
35            2 => Ok(BreakpointValue::AsyncCall),
36            3 => Ok(BreakpointValue::SignalError),
37            4 => Ok(BreakpointValue::OutOfGas),
38            5 => Ok(BreakpointValue::MemoryLimit),
39            _ => Err("unknown breakpoint".to_string()),
40        }
41    }
42}