Skip to main content

NonnegativeIntGet

Function NonnegativeIntGet 

Source
pub fn NonnegativeIntGet(
    key: &StorageKeyContractData,
    force_load_from_snapshot: bool,
) -> Result<(i128, bool, i128), SysErr>
Expand description

Retrieves the nonnegative integer value at the specified storage key. current_set_opt reports whether current_set holds a value; when it is false, current_set carries no information and should be ignored. If force_load_from_snapshot is true, then current_set_opt is always true on success. If the snapshot value is not an NNInt, or the previous write on that key was not an NNInt, then the syscall returns kSyscallErrorCodeInvalidSyscallInput. If the snapshot value does not exist, or has been deleted by the prior write, then it returns kSyscallErrorCodeStorageKeyNotExist. If force_load_from_snapshot is false, then the prior state of the item is ignored unless the prior write on that key is an NNInt write (in which case the parameters of that write are returned). If the prior write is not an NNInt, or was a deletion, then current_set_opt is false and current_add is 0.

§Arguments

  • key
  • force_load_from_snapshot

§Outputs

  • current_set
  • current_set_opt
  • current_add

This is a convenience wrapper around uninit_NonnegativeIntGet that returns the result as SyscallResult<T>.

§Errors

  • kSyscallErrorCodeStorageKeyNotExist: The storage key does not exist or has been deleted. Only returned if force_load_from_snapshot is true.

  • kSyscallErrorCodeInvalidSyscallInput: The storage key exists but contains a different type (e.g., bytestring instead of NNInt). Only returned if force_load_from_snapshot is true.