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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<V>
where V: ScryptoDecode { ... }
fn get_existing_substate<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> V
where V: ScryptoDecode { ... }
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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_>
where K: SubstateKeyContent { ... }
fn list_kinded_values<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
where K: SubstateKeyContent,
V: ScryptoDecode { ... }
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 = (u8, Vec<u8>)> + '_> { ... }
fn list_field_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (u8, V)> + '_>
where V: ScryptoDecode { ... }
fn list_field_entries<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
where K: TryFrom<u8>,
V: ScryptoDecode { ... }
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 = (Vec<u8>, Vec<u8>)> + '_> { ... }
fn list_map_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (Vec<u8>, V)> + '_>
where V: ScryptoDecode { ... }
fn list_map_entries<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>
where K: ScryptoDecode,
V: ScryptoDecode { ... }
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 = (([u8; 2], Vec<u8>), Vec<u8>)> + '_> { ... }
fn list_sorted_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (([u8; 2], Vec<u8>), V)> + '_>
where V: ScryptoDecode { ... }
}
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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<V>where
V: ScryptoDecode,
fn get_substate<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Option<V>where
V: ScryptoDecode,
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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Vwhere
V: ScryptoDecode,
fn get_existing_substate<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
substate_key: impl ResolvableSubstateKey<'a>,
) -> Vwhere
V: ScryptoDecode,
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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_>where
K: SubstateKeyContent,
fn list_kinded_raw_values<'a, K>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, Vec<u8>)> + '_>where
K: SubstateKeyContent,
Sourcefn list_kinded_values<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>where
K: SubstateKeyContent,
V: ScryptoDecode,
fn list_kinded_values<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>where
K: SubstateKeyContent,
V: ScryptoDecode,
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 = (u8, 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 = (u8, 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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (u8, V)> + '_>where
V: ScryptoDecode,
fn list_field_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (u8, V)> + '_>where
V: ScryptoDecode,
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, V>(
&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, V>( &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 = (Vec<u8>, 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 = (Vec<u8>, 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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (Vec<u8>, V)> + '_>where
V: ScryptoDecode,
fn list_map_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (Vec<u8>, V)> + '_>where
V: ScryptoDecode,
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, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>where
K: ScryptoDecode,
V: ScryptoDecode,
fn list_map_entries<'a, K, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (K, V)> + '_>where
K: ScryptoDecode,
V: ScryptoDecode,
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 = (([u8; 2], Vec<u8>), 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 = (([u8; 2], Vec<u8>), 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>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (([u8; 2], Vec<u8>), V)> + '_>where
V: ScryptoDecode,
fn list_sorted_values<'a, V>(
&self,
node_id: impl AsRef<NodeId>,
partition_number: PartitionNumber,
from_substate_key_inclusive: impl ResolvableOptionalSubstateKey<'a>,
) -> Box<dyn Iterator<Item = (([u8; 2], Vec<u8>), V)> + '_>where
V: ScryptoDecode,
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.