Skip to main content

RawStorage

Struct RawStorage 

Source
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

Source

pub fn put(key: &[u8], value: &[u8])

Write value to key in the executing contract’s persistent storage.

Source

pub fn delete(key: &[u8])

Delete key from the executing contract’s persistent storage.

Source

pub fn get_into(key: &[u8], buf: &mut [u8]) -> RawStorageGet

Read the value at key into buf.

Returns one of:

  • RawStorageGet::Found with the byte count actually written into buf when the key is present and the value fits.
  • RawStorageGet::Missing only when the runtime explicitly reports null/missing; Neo N3 commonly returns zero bytes for absent keys.
  • RawStorageGet::BufferTooSmall with the value’s true length when buf cannot hold it; the value bytes are NOT copied in this case.
Source

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.

Source

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.

Source

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.

Source

pub fn put_i64(key: &[u8], value: i64)

Convenience: store an i64 little-endian at key.

Source

pub fn put_u16(key: &[u8], value: u16)

Convenience: store a u16 little-endian at key.

Source

pub fn put_bool(key: &[u8], value: bool)

Convenience: store a bool (encoded as a single 0/1 byte) at key.

Source

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.

Source

pub fn get_i64_key_or_zero(key: i64) -> i64

Read an i64 value from an i64 key. Missing keys return 0.

Source

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.

Source

pub fn delete_i64_key(key: i64)

Delete an i64 key without touching wasm linear memory.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.