Skip to main content

neo_runtime/
storage.rs

1use neo_syscalls::NeoVMSyscall;
2use neo_types::*;
3
4/// Storage convenience helpers built on top of the syscall layer.
5pub struct NeoStorage;
6
7impl NeoStorage {
8    pub fn get_context() -> NeoResult<NeoStorageContext> {
9        NeoVMSyscall::storage_get_context()
10    }
11
12    pub fn get_read_only_context() -> NeoResult<NeoStorageContext> {
13        NeoVMSyscall::storage_get_read_only_context()
14    }
15
16    pub fn as_read_only(context: &NeoStorageContext) -> NeoResult<NeoStorageContext> {
17        NeoVMSyscall::storage_as_read_only(context)
18    }
19
20    pub fn get(context: &NeoStorageContext, key: &NeoByteString) -> NeoResult<NeoByteString> {
21        NeoVMSyscall::storage_get(context, key)
22    }
23
24    pub fn put(
25        context: &NeoStorageContext,
26        key: &NeoByteString,
27        value: &NeoByteString,
28    ) -> NeoResult<()> {
29        NeoVMSyscall::storage_put(context, key, value)
30    }
31
32    pub fn delete(context: &NeoStorageContext, key: &NeoByteString) -> NeoResult<()> {
33        NeoVMSyscall::storage_delete(context, key)
34    }
35
36    pub fn find(
37        context: &NeoStorageContext,
38        prefix: &NeoByteString,
39    ) -> NeoResult<NeoIterator<NeoValue>> {
40        NeoVMSyscall::storage_find(context, prefix)
41    }
42}