openvm_circuit/system/memory/
mod.rs

1use openvm_circuit_primitives_derive::AlignedBorrow;
2
3mod adapter;
4mod controller;
5pub mod merkle;
6mod offline;
7pub mod offline_checker;
8pub mod online;
9pub mod paged_vec;
10mod persistent;
11#[cfg(test)]
12mod tests;
13pub mod tree;
14mod volatile;
15
16pub use controller::*;
17pub use offline::*;
18pub use paged_vec::*;
19
20#[derive(PartialEq, Copy, Clone, Debug, Eq)]
21pub enum OpType {
22    Read = 0,
23    Write = 1,
24}
25
26/// The full pointer to a location in memory consists of an address space and a pointer within
27/// the address space.
28#[derive(Clone, Copy, Debug, PartialEq, Eq, AlignedBorrow)]
29#[repr(C)]
30pub struct MemoryAddress<S, T> {
31    pub address_space: S,
32    pub pointer: T,
33}
34
35impl<S, T> MemoryAddress<S, T> {
36    pub fn new(address_space: S, pointer: T) -> Self {
37        Self {
38            address_space,
39            pointer,
40        }
41    }
42
43    pub fn from<T1, T2>(a: MemoryAddress<T1, T2>) -> Self
44    where
45        T1: Into<S>,
46        T2: Into<T>,
47    {
48        Self {
49            address_space: a.address_space.into(),
50            pointer: a.pointer.into(),
51        }
52    }
53}
54
55#[derive(Clone, Copy, Debug, PartialEq, Eq, AlignedBorrow)]
56#[repr(C)]
57pub struct HeapAddress<S, T> {
58    pub address: MemoryAddress<S, T>,
59    pub data: MemoryAddress<S, T>,
60}