radix_engine_interface/api/
actor_key_value_entry_api.rs1use radix_common::data::scrypto::{scrypto_decode, ScryptoDecode};
2use radix_engine_interface::api::key_value_entry_api::KeyValueEntryHandle;
3use radix_engine_interface::api::{ActorStateHandle, CollectionIndex, LockFlags};
4use sbor::rust::vec::Vec;
5
6#[allow(clippy::ptr_arg)]
7pub trait SystemActorKeyValueEntryApi<E> {
8 fn actor_open_key_value_entry(
11 &mut self,
12 object_handle: ActorStateHandle,
13 collection_index: CollectionIndex,
14 key: &Vec<u8>,
15 flags: LockFlags,
16 ) -> Result<KeyValueEntryHandle, E>;
17
18 fn actor_remove_key_value_entry(
21 &mut self,
22 object_handle: ActorStateHandle,
23 collection_index: CollectionIndex,
24 key: &Vec<u8>,
25 ) -> Result<Vec<u8>, E>;
26
27 fn actor_remove_key_value_entry_typed<V: ScryptoDecode>(
30 &mut self,
31 object_handle: ActorStateHandle,
32 collection_index: CollectionIndex,
33 key: &Vec<u8>,
34 ) -> Result<Option<V>, E> {
35 let removed = self.actor_remove_key_value_entry(object_handle, collection_index, key)?;
36 let rtn = scrypto_decode(&removed).unwrap();
37 Ok(rtn)
38 }
39}