Skip to main content

thruput_sdk/sys_exn/
delete.rs

1//! System function: Delete
2
3use crate::re_throw::OrSyscallThrow;
4use crate::sys_result::delete as result;
5use crate::types::StorageKey;
6
7pub fn delete_shared(key: &StorageKey) {
8    result::delete_shared(key)
9        .or_syscall_throw(crate::sys::SyscallNo::kDeleteObject);
10}
11
12pub fn delete_exclusive(key: &StorageKey) {
13    result::delete_exclusive(key)
14        .or_syscall_throw(crate::sys::SyscallNo::kDeleteObject);
15}
16
17/// Delete anything stored at the given key.
18///
19/// Succeeds no matter what type of item is stored there, or if none is. After
20/// calling this function for a particular key, the storage location behaves as
21/// if it had never been set.
22///
23pub fn delete(key: &StorageKey, exclusive: bool) {
24    if exclusive {
25        delete_exclusive(key)
26    } else {
27        delete_shared(key)
28    }
29}