pub struct RawStorage;Expand description
Heap-free storage facade that operates on &[u8] slices.
wasm32 lowers each call to the translator’s System.Storage.* SYSCALL
helpers directly, so contracts that use this path do not depend on the
Rust allocator being functional inside NeoVM. Host (non-wasm32) builds
route through the existing NeoVMSyscall simulation so unit tests behave
the same as on wasm32.
Implementations§
Source§impl RawStorage
impl RawStorage
Sourcepub fn put(key: &[u8], value: &[u8])
pub fn put(key: &[u8], value: &[u8])
Write value to key in the executing contract’s persistent storage.
Sourcepub fn get_into(key: &[u8], buf: &mut [u8]) -> RawStorageGet
pub fn get_into(key: &[u8], buf: &mut [u8]) -> RawStorageGet
Read the value at key into buf.
Returns one of:
RawStorageGet::Foundwith the byte count actually written intobufwhen the key is present and the value fits.RawStorageGet::Missingonly when the runtime explicitly reports null/missing; Neo N3 commonly returns zero bytes for absent keys.RawStorageGet::BufferTooSmallwith the value’s true length whenbufcannot hold it; the value bytes are NOT copied in this case.
Sourcepub fn get_i64(key: &[u8]) -> Option<i64>
pub fn get_i64(key: &[u8]) -> Option<i64>
Read an exact 8-byte little-endian i64 at key. Returns None for
missing keys or for stored values whose length is not exactly 8.
Sourcepub fn get_u16(key: &[u8]) -> Option<u16>
pub fn get_u16(key: &[u8]) -> Option<u16>
Read an exact 2-byte little-endian u16 at key. Returns None for
missing keys or for stored values whose length is not exactly 2.
Sourcepub fn get_bool(key: &[u8]) -> Option<bool>
pub fn get_bool(key: &[u8]) -> Option<bool>
Read an exact 1-byte boolean at key. Returns None for missing keys
or for stored values whose length is not exactly 1.
Sourcepub fn put_bool(key: &[u8], value: bool)
pub fn put_bool(key: &[u8], value: bool)
Convenience: store a bool (encoded as a single 0/1 byte) at key.
Sourcepub fn put_i64_key(key: i64, value: i64)
pub fn put_i64_key(key: i64, value: i64)
Store an i64 value under an i64 key without touching wasm linear
memory. On wasm32 this lowers directly to System.Storage.Put.
Sourcepub fn get_i64_key_or_zero(key: i64) -> i64
pub fn get_i64_key_or_zero(key: i64) -> i64
Read an i64 value from an i64 key. Missing keys return 0.
Sourcepub fn has_i64_key(key: i64) -> bool
pub fn has_i64_key(key: i64) -> bool
Check whether an i64 key has a stored integer value.
Neo Express surfaces absent direct keys as empty bytes. The translator
therefore treats any non-empty Storage.Get result as present.
Sourcepub fn delete_i64_key(key: i64)
pub fn delete_i64_key(key: i64)
Delete an i64 key without touching wasm linear memory.