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>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: &SubstateKey,
        flags: LockFlags,
        default: Option<F>,
        lock_data: L
    ) -> Result<u32, RuntimeError>
       where F: FnOnce() -> IndexedScryptoValue;
    fn kernel_get_lock_data(
        &mut self,
        lock_handle: u32
    ) -> Result<L, RuntimeError>;
    fn kernel_close_substate(
        &mut self,
        lock_handle: u32
    ) -> Result<(), RuntimeError>;
    fn kernel_read_substate(
        &mut self,
        lock_handle: u32
    ) -> Result<&IndexedScryptoValue, RuntimeError>;
    fn kernel_write_substate(
        &mut self,
        lock_handle: u32,
        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<(([u8; 2], Vec<u8>), IndexedScryptoValue)>, RuntimeError>;
    fn kernel_scan_keys<K>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        count: u32
    ) -> Result<Vec<SubstateKey>, RuntimeError>
       where K: SubstateKeyContent + 'static;
    fn kernel_drain_substates<K>(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        count: u32
    ) -> Result<Vec<(SubstateKey, IndexedScryptoValue)>, RuntimeError>
       where K: SubstateKeyContent + 'static;

    // Provided method
    fn kernel_open_substate(
        &mut self,
        node_id: &NodeId,
        partition_num: PartitionNumber,
        substate_key: &SubstateKey,
        flags: LockFlags,
        lock_data: L
    ) -> Result<u32, 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>( &mut self, node_id: &NodeId, partition_num: PartitionNumber, substate_key: &SubstateKey, flags: LockFlags, default: Option<F>, lock_data: L ) -> Result<u32, RuntimeError>

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

source

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

Retrieves info related to a lock

source

fn kernel_close_substate( &mut self, lock_handle: u32 ) -> 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: u32 ) -> Result<&IndexedScryptoValue, RuntimeError>

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

source

fn kernel_write_substate( &mut self, lock_handle: u32, 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<(([u8; 2], Vec<u8>), 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>( &mut self, node_id: &NodeId, partition_num: PartitionNumber, count: u32 ) -> Result<Vec<SubstateKey>, RuntimeError>
where K: SubstateKeyContent + 'static,

source

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

Provided Methods§

source

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

Object Safety§

This trait is not object safe.

Implementors§