pub trait SubstateDatabaseExtensions: SubstateDatabase {
Show 14 methods
// Provided methods
fn get_raw_substate<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<Vec<u8>> { ... }
fn get_substate<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<V> { ... }
fn get_existing_substate<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> V { ... }
fn list_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_> { ... }
fn list_kinded_raw_values<'a, K: SubstateKeyContent>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_> { ... }
fn list_kinded_values<'a, K: SubstateKeyContent, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_> { ... }
fn list_field_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (FieldKey, Vec<u8>)> + '_> { ... }
fn list_field_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (FieldKey, V)> + '_> { ... }
fn list_field_entries<'a, K: TryFrom<FieldKey>, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_> { ... }
fn list_map_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (MapKey, Vec<u8>)> + '_> { ... }
fn list_map_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (MapKey, V)> + '_> { ... }
fn list_map_entries<'a, K: ScryptoDecode, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_> { ... }
fn list_sorted_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (SortedKey, Vec<u8>)> + '_> { ... }
fn list_sorted_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (SortedKey, V)> + '_> { ... }
}
Expand description
These are a separate trait so that SubstateDatabase
stays object-safe,
and can be used as dyn SubstateDatabase
.
Generic parameters aren’t permitted on object-safe traits.
Provided Methods§
Sourcefn get_raw_substate<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<Vec<u8>>
fn get_raw_substate<'a>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, substate_key: impl ResolvableSubstateKey<'a>, ) -> Option<Vec<u8>>
Sourcefn get_substate<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<V>
fn get_substate<'a, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, substate_key: impl ResolvableSubstateKey<'a>, ) -> Option<V>
Gets the substate’s value, if it exists, and returns it decoded as Some(V)
.
If it doesn’t exist, None
is returned.
§Panics
This method panics if:
- There is an error decoding the value into the
V
.
§Example use:
let type_info_substate = db.get_substate::<TypeInfoSubstate>(
PACKAGE_PACKAGE,
TYPE_INFO_FIELD_PARTITION,
TypeInfoField::TypeInfo,
)?;
Sourcefn get_existing_substate<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> V
fn get_existing_substate<'a, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, substate_key: impl ResolvableSubstateKey<'a>, ) -> V
Gets the value of a subsate which is expected to exist, returns it decoded as V
.
§Panics
This method panics if:
- The substate doesn’t exist in the database.
- There is an error decoding the value into the
V
.
§Example use:
let existing_type_info_substate: TypeInfoSubstate = db.get_existing_substate(
PACKAGE_PACKAGE,
TYPE_INFO_FIELD_PARTITION,
TypeInfoField::TypeInfo,
)?;
Sourcefn list_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_>
fn list_raw_values<'a>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (DbSortKey, Vec<u8>)> + '_>
Returns an iterator of the substates of a partition from an inclusive start cursor.
The iterator returns raw keys and values.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
Sourcefn list_kinded_raw_values<'a, K: SubstateKeyContent>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_>
fn list_kinded_raw_values<'a, K: SubstateKeyContent>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_>
Sourcefn list_kinded_values<'a, K: SubstateKeyContent, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
fn list_kinded_values<'a, K: SubstateKeyContent, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (K, V)> + '_>
Returns an iterator of the substates of a partition from an inclusive start cursor.
The iterator returns K
and V
for each substate.
The caller must specify K
as FieldKey
, MapKey
or SortedKey
.
The value type V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error decoding the value bytes into
V
.
Sourcefn list_field_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (FieldKey, Vec<u8>)> + '_>
fn list_field_raw_values<'a>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (FieldKey, Vec<u8>)> + '_>
Returns an iterator of the substates of a field partition from an inclusive start cursor.
The iterator returns the FieldKey = u8
and the raw value for each substate.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
Sourcefn list_field_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (FieldKey, V)> + '_>
fn list_field_values<'a, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (FieldKey, V)> + '_>
Returns an iterator of the substates of a field partition from an inclusive start cursor.
The iterator returns the FieldKey = u8
and the decoded value V
for each substate.
The value type V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error decoding the value bytes into
V
.
Sourcefn list_field_entries<'a, K: TryFrom<FieldKey>, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
fn list_field_entries<'a, K: TryFrom<FieldKey>, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (K, V)> + '_>
Returns an iterator of the substates of a field partition from an inclusive start cursor.
The iterator returns the decoded key type K
and the decoded value V
for each substate.
The key type K
and value types V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error converting the field key byte into
K
. - There is an error decoding the value bytes into
V
.
Sourcefn list_map_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (MapKey, Vec<u8>)> + '_>
fn list_map_raw_values<'a>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (MapKey, Vec<u8>)> + '_>
Returns an iterator of the substates of a map partition from an inclusive start cursor.
The iterator returns the MapKey = Vec<u8>
and the raw value for each substate.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
Sourcefn list_map_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (MapKey, V)> + '_>
fn list_map_values<'a, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (MapKey, V)> + '_>
Returns an iterator of the substates of a map partition from an inclusive start cursor.
The iterator returns the MapKey = Vec<u8>
and the decoded value V
for each substate.
The value type V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error decoding the value bytes into
V
.
Sourcefn list_map_entries<'a, K: ScryptoDecode, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
fn list_map_entries<'a, K: ScryptoDecode, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (K, V)> + '_>
Returns an iterator of the substates of a map partition from an inclusive start cursor.
The iterator returns the decoded key type K
and the decoded value V
for each substate.
The key type K
and value types V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error decoding the field bytes into
K
. - There is an error decoding the value bytes into
V
.
Sourcefn list_sorted_raw_values<'a>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (SortedKey, Vec<u8>)> + '_>
fn list_sorted_raw_values<'a>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (SortedKey, Vec<u8>)> + '_>
Returns an iterator of the substates of a sorted partition from an inclusive start cursor.
The iterator returns the SortedKey = ([u8; 2], Vec<u8>)
and the raw value for each substate.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
Sourcefn list_sorted_values<'a, V: ScryptoDecode>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (SortedKey, V)> + '_>
fn list_sorted_values<'a, V: ScryptoDecode>( &self, node_id: impl AsRef<NodeId>, partition_number: PartitionNumber, from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>, ) -> Box<dyn Iterator<Item = (SortedKey, V)> + '_>
Returns an iterator of the substates of a sorted partition from an inclusive start cursor.
The iterator returns the SortedKey = ([u8; 2], Vec<u8>)
and the decoded value V
for each substate. The value type V
can be specified or inferred.
Pass None::<SubstateKey>
as the cursor to iterate from the start of the partition.
§Panics
This method panics if:
- There is an error decoding the value bytes into
V
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.