evm_interpreter/error/
mod.rs

1use alloc::boxed::Box;
2
3mod exit;
4mod trap;
5
6pub use self::{exit::*, trap::*};
7
8/// Capture represents the result of execution.
9#[derive(Debug, Eq, PartialEq)]
10pub enum Capture<E, T> {
11	/// The machine has exited. It cannot be executed again.
12	Exit(E),
13	/// The machine has trapped. It is waiting for external information, and can
14	/// be executed again.
15	Trap(Box<T>),
16}
17
18impl<E, T> Capture<E, T> {
19	pub fn exit(self) -> Option<E> {
20		match self {
21			Self::Exit(e) => Some(e),
22			Self::Trap(_) => None,
23		}
24	}
25
26	pub fn trap(self) -> Option<Box<T>> {
27		match self {
28			Self::Exit(_) => None,
29			Self::Trap(t) => Some(t),
30		}
31	}
32}