zephyr_vm/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![warn(missing_docs)]

//! ## The Zephyr VM host environment.
//!
//! Implementation of the Zephyr VM, the core of Mercury's code execution environment.
//! Even if Zephyr is built to be used in Mercury, it is implementation-agnostic
//! and can be integrated in any kind of implementation.

pub mod snapshot;

pub mod budget;
pub mod db;
pub mod host;
pub mod vm;

mod soroban_host_gen;

#[allow(missing_docs)]
pub mod error;

pub mod stack;
pub mod vm_context;

use anyhow::Result;

#[cfg(feature = "testutils")]
pub mod testutils;

#[cfg(test)]
pub mod test;

/// Standard object for Zephyr. This trait must be implemented for all
/// components that are encompassed by the Zephyr VM, specifically
/// the database implementation.
pub trait ZephyrStandard {
    /// Returns the standard zephyr object.
    fn zephyr_standard() -> Result<Self>
    where
        Self: Sized;
}

// TODO: make mocks testutils only.
/// Standard mocked Zephyr object. This trait must be implemented for all
/// components that are encompassed by the Zephyr VM that required mocks
/// for testing.
pub trait ZephyrMock {
    /// Returns the mocked object.
    fn mocked() -> Result<Self>
    where
        Self: Sized;
}