evm_interpreter/error/
mod.rs

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