radix_engine_interface/api/
actor_api.rs

1use crate::api::field_api::FieldHandle;
2use crate::api::{ActorRefHandle, FieldIndex};
3use crate::internal_prelude::*;
4use crate::types::*;
5use bitflags::bitflags;
6use radix_engine_interface::api::{ActorStateHandle, LockFlags};
7use sbor::rust::string::String;
8use sbor::rust::vec::Vec;
9
10bitflags! {
11    #[derive(Sbor)]
12    pub struct EventFlags: u32 {
13        /// With this flag on, an event will not be reverted if the transaction fails.
14        const FORCE_WRITE = 0b00000001;
15    }
16}
17
18/// Api which exposes methods in the context of the actor
19pub trait SystemActorApi<E> {
20    /// Retrieve the current blueprint id
21    fn actor_get_blueprint_id(&mut self) -> Result<BlueprintId, E>;
22
23    /// Retrieve the current method actor's node id
24    fn actor_get_node_id(&mut self, ref_handle: ActorRefHandle) -> Result<NodeId, E>;
25
26    /// Check if a feature is enabled for a given object
27    fn actor_is_feature_enabled(
28        &mut self,
29        state_handle: ActorStateHandle,
30        feature: &str,
31    ) -> Result<bool, E>;
32
33    /// Open a field in a given object for reading/writing
34    fn actor_open_field(
35        &mut self,
36        state_handle: ActorStateHandle,
37        field: FieldIndex,
38        flags: LockFlags,
39    ) -> Result<FieldHandle, E>;
40
41    /// Emits an event of the current actor
42    fn actor_emit_event(
43        &mut self,
44        event_name: String,
45        event_data: Vec<u8>,
46        event_flags: EventFlags,
47    ) -> Result<(), E>;
48}