pub trait KernelSubstateApi<L> {
    // Required methods
    fn kernel_mark_substate_as_transient(
        &mut self,
        node_id: NodeId,
        partition_num: PartitionNumber,
        key: SubstateKey
    ) -> Result<(), RuntimeError>;
    fn kernel_open_substate_with_default<F: FnOnce() -> IndexedScryptoValue>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: &SubstateKey,
        flags: LockFlags,
        default: Option<F>,
        lock_data: L
    ) -> Result<SubstateHandle, RuntimeError>;
    fn kernel_get_lock_data(
        &mut self,
        lock_handle: SubstateHandle
    ) -> Result<L, RuntimeError>;
    fn kernel_close_substate(
        &mut self,
        lock_handle: SubstateHandle
    ) -> Result<(), RuntimeError>;
    fn kernel_read_substate(
        &mut self,
        lock_handle: SubstateHandle
    ) -> Result<&IndexedScryptoValue, RuntimeError>;
    fn kernel_write_substate(
        &mut self,
        lock_handle: SubstateHandle,
        value: IndexedScryptoValue
    ) -> Result<(), RuntimeError>;
    fn kernel_set_substate(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: SubstateKey,
        value: IndexedScryptoValue
    ) -> Result<(), RuntimeError>;
    fn kernel_remove_substate(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: &SubstateKey
    ) -> Result<Option<IndexedScryptoValue>, RuntimeError>;
    fn kernel_scan_sorted_substates(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        count: u32
    ) -> Result<Vec<(SortedKey, IndexedScryptoValue)>, RuntimeError>;
    fn kernel_scan_keys<K: SubstateKeyContent + 'static>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        count: u32
    ) -> Result<Vec<SubstateKey>, RuntimeError>;
    fn kernel_drain_substates<K: SubstateKeyContent + 'static>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        count: u32
    ) -> Result<Vec<(SubstateKey, IndexedScryptoValue)>, RuntimeError>;

    // Provided method
    fn kernel_open_substate(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: &SubstateKey,
        flags: LockFlags,
        lock_data: L
    ) -> Result<SubstateHandle, RuntimeError> { ... }
}
Expand description

API for managing substates within nodes

Required Methods§

source

fn kernel_mark_substate_as_transient( &mut self, node_id: NodeId, partition_num: PartitionNumber, key: SubstateKey ) -> Result<(), RuntimeError>

Marks a substate as transient, or a substate which was never and will never be persisted

source

fn kernel_open_substate_with_default<F: FnOnce() -> IndexedScryptoValue>( &mut self, node_id: &NodeId, partition_num: PartitionNumber, substate_key: &SubstateKey, flags: LockFlags, default: Option<F>, lock_data: L ) -> Result<SubstateHandle, RuntimeError>

Locks a substate to make available for reading and/or writing

source

fn kernel_get_lock_data( &mut self, lock_handle: SubstateHandle ) -> Result<L, RuntimeError>

Retrieves info related to a lock

source

fn kernel_close_substate( &mut self, lock_handle: SubstateHandle ) -> Result<(), RuntimeError>

Drops the handle on some substate, if the handle is a force write, updates are flushed. No updates should occur if an error is returned.

source

fn kernel_read_substate( &mut self, lock_handle: SubstateHandle ) -> Result<&IndexedScryptoValue, RuntimeError>

Reads the value of the substate locked by the given lock handle

source

fn kernel_write_substate( &mut self, lock_handle: SubstateHandle, value: IndexedScryptoValue ) -> Result<(), RuntimeError>

Writes a value to the substate locked by the given lock handle

source

fn kernel_set_substate( &mut self, node_id: &NodeId, partition_num: PartitionNumber, substate_key: SubstateKey, value: IndexedScryptoValue ) -> Result<(), RuntimeError>

Sets a value to a substate without checking for the original value.

Clients must ensure that this isn’t used in conjunction with shardable substates; otherwise, the behavior is undefined

source

fn kernel_remove_substate( &mut self, node_id: &NodeId, partition_num: PartitionNumber, substate_key: &SubstateKey ) -> Result<Option<IndexedScryptoValue>, RuntimeError>

Removes a substate from a node and returns the original value.

Clients must ensure that this isn’t used in conjunction with virtualized substates; otherwise, the behavior is undefined

source

fn kernel_scan_sorted_substates( &mut self, node_id: &NodeId, partition_num: PartitionNumber, count: u32 ) -> Result<Vec<(SortedKey, IndexedScryptoValue)>, RuntimeError>

Reads substates under a node in sorted lexicographical order

Clients must ensure that this isn’t used in conjunction with virtualized substates; otherwise, the behavior is undefined

source

fn kernel_scan_keys<K: SubstateKeyContent + 'static>( &mut self, node_id: &NodeId, partition_num: PartitionNumber, count: u32 ) -> Result<Vec<SubstateKey>, RuntimeError>

source

fn kernel_drain_substates<K: SubstateKeyContent + 'static>( &mut self, node_id: &NodeId, partition_num: PartitionNumber, count: u32 ) -> Result<Vec<(SubstateKey, IndexedScryptoValue)>, RuntimeError>

Provided Methods§

source

fn kernel_open_substate( &mut self, node_id: &NodeId, partition_num: PartitionNumber, substate_key: &SubstateKey, flags: LockFlags, lock_data: L ) -> Result<SubstateHandle, RuntimeError>

Object Safety§

This trait is not object safe.

Implementors§