pub struct TestEnvironment<D>(/* private fields */)
where
D: SubstateDatabase + CommittableSubstateDatabase + 'static;
Expand description
The environment that all tests of this testing framework are run against.
This struct may be thought of as the main struct in this testing framework which encapsulates a
a self-contained instance of the Radix Engine ([EncapsulatedRadixEngine
]). The functionality
of the Radix Engine is exposed through the SystemApi
which makes this testing environment no
less capable than Scrypto code.
§Introduction
This testing framework is designed to allow you to write Scrypto-like code and use that to test
your packages and blueprints and follows a different approach from the LedgerSimulator
class. The
test-runner is an in-memory ledger simulator which you can interact with as a user that submits
transactions to the network. The approach followed by this testing framework is different,
instead of submitting transactions, you’re making invocations to the Radix Engine, getting
results back, and then writing assertions against what you got back.
Both the LedgerSimulator and this testing framework will prove to be useful throughout your blueprint
development journey. As an example, this testing framework allows you to disable some of kernel
modules that may get in your way when writing tests so it may be an optimal framework to use to
ensure that the “math checks out” in your blueprint code without needing to think about costing
or auth. However, when you’re reaching the final stages of developing a blueprint you may want
tests that check that interactions with your blueprint will succeed in a simulated setting that
is close to the real setting, which is when the LedgerSimulator
comes in. Overall, we may put these
two frameworks into two categories: This framework (named scrypto-test) is a framework for unit
testing your blueprints and is a good framework to use to check that your DeFi logic is correct.
The LedgerSimulator
is an integration testing or an end-to-end testing framework to test that your
blueprints work in a simulated ledger with all of the costing limits, substate limits, and other
limits applied.
§Features
This framework has many new features that developers may find useful when testing their packages some of those features are:
- The ability to create mock
Bucket
s andProof
s through two main ways: by creating them out of thin air, and by disabling the auth module and minting them. This functionality can be found in theBucketFactory
andProofFactory
structs and theCreationStrategy
. - The ability to query the contents of
Bucket
s andProof
s for the purpose of writing assertions against them. Not only that, but this testing framework allows you to call any method you wish on these nodes. As an example, in a test, you can get aBucket
and then create a proof out of it in manner similar to Scrypto. - The ability to enable and disable kernel modules at runtime. The Radix Engine kernel is quite
modular with concepts such as auth, costing, and limits being implemented as kernel modules.
Disabling or enabling kernel modules at runtime can prove to be quite useful when writing DeFi
tests. As an example, you may want to not think about costing at all when writing tests and
thus you may opt to disable the costing module entirely and continue your test without it.
This can be done through
TestEnvironment::disable_costing_module
. - This testing framework uses test bindings to provide a higher-level API for calling methods
and functions on a blueprint without the need to do raw
TestEnvironment::call_method_typed
orTestEnvironment::call_function_typed
. The test bindings are generated by the blueprint macro and are feature gated behind atest
feature.
§Getting Started
The following example shows a very simple test that gets XRD from the faucet and then asserts that the amount is equal to what we expect.
use scrypto_test::prelude::*;
fn my_test() -> Result<(), RuntimeError> {
// Arrange
let mut env = TestEnvironment::new();
// Act
let bucket = env.call_method_typed::<_, _, Bucket>(
FAUCET,
"free",
&(),
)?;
// Assert
let amount = bucket.amount(&mut env)?;
assert_eq!(amount, dec!("10000"));
Ok(())
}
A few things to note about the code you see above:
- There is no transactions, worktop, receipt, manifests or anything of that sort! This part is “not just hidden” from this testing framework but is actually non existent! The approach that framework of wrapping a self-contained Radix Engine means that there is no need for manifests or other transaction concepts.
- Methods such as
Bucket::amount
can be called to get the amount of resources in a bucket and then assert against that.
§Manipulating Kernel Modules
At runtime, the kernel modules can be enabled or disabled. For each kernel module there are four
methods on the TestEnvironment
:
- A method to enable the kernel module (e.g.,
TestEnvironment::enable_costing_module
). - A method to disable the kernel module (e.g.,
TestEnvironment::disable_costing_module
). - A method to perform some action in a callback with the module enabled (e.g.,
TestEnvironment::with_costing_module_enabled
). - A method to perform some action in a callback with the module disabled (e.g.,
TestEnvironment::with_costing_module_disabled
).
The simple enable and disable methods are quite straightforward: call them to enable or disable
a kernel module. The with_*
methods are a little bit more intricate, they allow you to perform
some actions with a specific kernel either enabled or disabled and then resets the state of the
kernel modules afterwards. As an example:
use scrypto_test::prelude::*;
// Arrange
let mut env = TestEnvironment::new();
// Act
let bucket = env.with_auth_module_disabled(|env| {
/* Auth Module is disabled just before this point */
ResourceManager(XRD).mint_fungible(100.into(), env)
/* Kernel modules are reset just after this point. */
})?;
// Assert
let amount = bucket.amount(&mut env)?;
assert_eq!(amount, dec!("100"));
§Common Arranges or Teardowns
There are cases where you may have many tests that all share a large portion of your arrange or teardown logic. While this framework does not specifically provide solutions for this, there are many useful Rust patterns that may be employed here to allow you to do this: the simplest and the most elegant is probably by using callback functions.
Imagine this, you’re building a Dex and many of the tests you write require you to have two resources with a very large supply so you can write your tests with. You can achieve this by doing something like:
use scrypto_test::prelude::*;
pub fn two_resource_environment<F>(func: F)
where
F: FnOnce(DefaultTestEnvironment, FungibleBucket, FungibleBucket),
{
let mut env = TestEnvironment::new();
let bucket1 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(dec!("100000000000"), &mut env)
.unwrap();
let bucket2 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(dec!("100000000000"), &mut env)
.unwrap();
func(env, bucket1, bucket2)
/* Potential teardown happens here */
}
#[test]
fn contribution_provides_expected_amount_of_pool_units() {
two_resource_environment(|mut env, bucket1, bucket2| {
/* Your test goes here */
})
}
You may have a function like two_resource_environment
seen above which sets up the environment
and then some callback and potentially then executes some teardown code. Another way to do this
would be through simple factory and destructor methods.
Implementations§
Source§impl<D> TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Sourcepub fn call_function_typed<I, O>(
&mut self,
package_address: PackageAddress,
blueprint_name: &str,
function_name: &str,
args: &I,
) -> Result<O, RuntimeError>where
I: ScryptoEncode,
O: ScryptoDecode,
pub fn call_function_typed<I, O>(
&mut self,
package_address: PackageAddress,
blueprint_name: &str,
function_name: &str,
args: &I,
) -> Result<O, RuntimeError>where
I: ScryptoEncode,
O: ScryptoDecode,
Invokes a function on the provided blueprint and package with the given arguments.
This method is a typed version of the SystemBlueprintApi::call_function
which Scrypto
encodes the arguments and Scrypto decodes the returns on behalf of the caller. This method
assumes that the caller is correct about the argument and return types and panics if the
encoding or decoding fails.
§Arguments
package_address
:PackageAddress
- The address of the package that contains the blueprint.blueprint_name
:&str
- The name of the blueprint.function_name
:&str
- The nae of the function.args
:&I
- The arguments to invoke the method with. This is a generic arguments that is fulfilled by any type that implementsScryptoEncode
.
§Returns
Result<O, RuntimeError>
- The returns from the method invocation. If the invocation was successful aResult::Ok
is returned, otherwise aResult::Err
is returned. TheResult::Ok
variant is a generic that’s fulfilled by any type that implementsScryptoDecode
.
§Panics
This method panics in the following two cases:
- Through an unwrap when calling
scrypto_encode
on the method arguments. Please consult the SBOR documentation on more information on why SBOR encoding may fail. - Through an unwrap when calling
scrypto_decode
on the returns. This panics if the type could be decoded as the desired output type.
Sourcepub fn call_method_typed<N, I, O>(
&mut self,
node_id: N,
method_name: &str,
args: &I,
) -> Result<O, RuntimeError>
pub fn call_method_typed<N, I, O>( &mut self, node_id: N, method_name: &str, args: &I, ) -> Result<O, RuntimeError>
Invokes a method on the main module of a node with the provided typed arguments.
This method is a typed version of the SystemObjectApi::call_method
which Scrypto encodes
the arguments and Scrypto decodes the returns on behalf of the caller. This method assumes
that the caller is correct about the argument and return types and panics if the encoding or
decoding fails.
§Arguments
node_id
:T
- The node to invoke the method on. This is a generic argument that’s fulfilled by any type that implementsInto<NodeId>
, thus, any address type can be used.method_name
:&str
- The name of the method to invoke.args
:&I
- The arguments to invoke the method with. This is a generic arguments that is fulfilled by any type that implementsScryptoEncode
.
§Returns
Result<O, RuntimeError>
- The returns from the method invocation. If the invocation was successful aResult::Ok
is returned, otherwise aResult::Err
is returned. TheResult::Ok
variant is a generic that’s fulfilled by any type that implementsScryptoDecode
.
§Panics
This method panics in the following two cases:
- Through an unwrap when calling
scrypto_encode
on the method arguments. Please consult the SBOR documentation on more information on why SBOR encoding may fail. - Through an unwrap when calling
scrypto_decode
on the returns. This panics if the type could be decoded as the desired output type.
Sourcepub fn call_direct_access_method_typed<N, I, O>(
&mut self,
node_id: N,
method_name: &str,
args: &I,
) -> Result<O, RuntimeError>
pub fn call_direct_access_method_typed<N, I, O>( &mut self, node_id: N, method_name: &str, args: &I, ) -> Result<O, RuntimeError>
Invokes a method on the main module of a node with the provided typed arguments.
This method is a typed version of the SystemObjectApi::call_method
which Scrypto encodes
the arguments and Scrypto decodes the returns on behalf of the caller. This method assumes
that the caller is correct about the argument and return types and panics if the encoding or
decoding fails.
§Arguments
node_id
:T
- The node to invoke the method on. This is a generic argument that’s fulfilled by any type that implementsInto<NodeId>
, thus, any address type can be used.method_name
:&str
- The name of the method to invoke.args
:&I
- The arguments to invoke the method with. This is a generic arguments that is fulfilled by any type that implementsScryptoEncode
.
§Returns
Result<O, RuntimeError>
- The returns from the method invocation. If the invocation was successful aResult::Ok
is returned, otherwise aResult::Err
is returned. TheResult::Ok
variant is a generic that’s fulfilled by any type that implementsScryptoDecode
.
§Panics
This method panics in the following two cases:
- Through an unwrap when calling
scrypto_encode
on the method arguments. Please consult the SBOR documentation on more information on why SBOR encoding may fail. - Through an unwrap when calling
scrypto_decode
on the returns. This panics if the type could be decoded as the desired output type.
Sourcepub fn call_module_method_typed<N, I, O>(
&mut self,
node_id: N,
module: AttachedModuleId,
method_name: &str,
args: &I,
) -> Result<O, RuntimeError>
pub fn call_module_method_typed<N, I, O>( &mut self, node_id: N, module: AttachedModuleId, method_name: &str, args: &I, ) -> Result<O, RuntimeError>
Invokes a method on a module of a node with the provided typed arguments.
This method is a typed version of the SystemObjectApi::call_method
which Scrypto encodes
the arguments and Scrypto decodes the returns on behalf of the caller. This method assumes
that the caller is correct about the argument and return types and panics if the encoding or
decoding fails.
§Arguments
node_id
:T
- The node to invoke the method on. This is a generic argument that’s fulfilled by any type that implementsInto<NodeId>
, thus, any address type can be used.module
:AttachedModuleId
- The module id.method_name
:&str
- The name of the method to invoke.args
:&I
- The arguments to invoke the method with. This is a generic arguments that is fulfilled by any type that implementsScryptoEncode
.
§Returns
Result<O, RuntimeError>
- The returns from the method invocation. If the invocation was successful aResult::Ok
is returned, otherwise aResult::Err
is returned. TheResult::Ok
variant is a generic that’s fulfilled by any type that implementsScryptoDecode
.
§Panics
This method panics in the following two cases:
- Through an unwrap when calling
scrypto_encode
on the method arguments. Please consult the SBOR documentation on more information on why SBOR encoding may fail. - Through an unwrap when calling
scrypto_decode
on the returns. This panics if the type could be decoded as the desired output type.
pub fn with_kernel<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&TestKernel<'_, D>) -> O,
pub fn with_kernel_mut<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut TestKernel<'_, D>) -> O,
Sourcepub fn enable_kernel_trace_module(&mut self)
pub fn enable_kernel_trace_module(&mut self)
Enables the kernel trace kernel module of the Radix Engine.
Sourcepub fn enable_limits_module(&mut self)
pub fn enable_limits_module(&mut self)
Enables the limits kernel module of the Radix Engine.
Sourcepub fn enable_costing_module(&mut self)
pub fn enable_costing_module(&mut self)
Enables the costing kernel module of the Radix Engine.
Sourcepub fn enable_auth_module(&mut self)
pub fn enable_auth_module(&mut self)
Enables the auth kernel module of the Radix Engine.
Sourcepub fn enable_transaction_runtime_module(&mut self)
pub fn enable_transaction_runtime_module(&mut self)
Enables the transaction env kernel module of the Radix Engine.
Sourcepub fn enable_execution_trace_module(&mut self)
pub fn enable_execution_trace_module(&mut self)
Enables the execution trace kernel module of the Radix Engine.
Sourcepub fn disable_kernel_trace_module(&mut self)
pub fn disable_kernel_trace_module(&mut self)
Disables the kernel trace kernel module of the Radix Engine.
Sourcepub fn disable_limits_module(&mut self)
pub fn disable_limits_module(&mut self)
Disables the limits kernel module of the Radix Engine.
Sourcepub fn disable_costing_module(&mut self)
pub fn disable_costing_module(&mut self)
Disables the costing kernel module of the Radix Engine.
Sourcepub fn disable_auth_module(&mut self)
pub fn disable_auth_module(&mut self)
Disables the auth kernel module of the Radix Engine.
Sourcepub fn disable_transaction_runtime_module(&mut self)
pub fn disable_transaction_runtime_module(&mut self)
Disables the transaction env kernel module of the Radix Engine.
Sourcepub fn disable_execution_trace_module(&mut self)
pub fn disable_execution_trace_module(&mut self)
Disables the execution trace kernel module of the Radix Engine.
Sourcepub fn with_kernel_trace_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_kernel_trace_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the kernel trace kernel module enabled and then resets the
state of the kernel modules.
Sourcepub fn with_limits_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_limits_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the limits kernel module enabled and then resets the state
of the kernel modules.
Sourcepub fn with_costing_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_costing_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the costing kernel module enabled and then resets the state
of the kernel modules.
Sourcepub fn with_auth_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_auth_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the auth kernel module enabled and then resets the state of
the kernel modules.
Sourcepub fn with_transaction_runtime_module_enabled<F, O>(
&mut self,
callback: F,
) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_transaction_runtime_module_enabled<F, O>(
&mut self,
callback: F,
) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the transaction env kernel module enabled and then
resets the state of the kernel modules.
Sourcepub fn with_execution_trace_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_execution_trace_module_enabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the execution trace kernel module enabled and then resets
the state of the kernel modules.
Sourcepub fn with_kernel_trace_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_kernel_trace_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the kernel trace kernel module disabled and then resets the
state of the kernel modules.
Sourcepub fn with_limits_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_limits_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the limits kernel module disabled and then resets the state
of the kernel modules.
Sourcepub fn with_costing_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_costing_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the costing kernel module disabled and then resets the
state of the kernel modules.
Sourcepub fn with_auth_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_auth_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the auth kernel module disabled and then resets the state
of the kernel modules.
Sourcepub fn with_transaction_runtime_module_disabled<F, O>(
&mut self,
callback: F,
) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_transaction_runtime_module_disabled<F, O>(
&mut self,
callback: F,
) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the transaction env kernel module disabled and then
resets the state of the kernel modules.
Sourcepub fn with_execution_trace_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
pub fn with_execution_trace_module_disabled<F, O>(&mut self, callback: F) -> Owhere
F: FnOnce(&mut Self) -> O,
Calls the passed callback
with the execution trace kernel module disabled and then resets
the state of the kernel modules.
Sourcepub fn enabled_modules(&self) -> EnabledModules
pub fn enabled_modules(&self) -> EnabledModules
Returns the bit flags representing the currently enabled kernel modules.
Sourcepub fn set_enabled_modules(&mut self, enabled_modules: EnabledModules)
pub fn set_enabled_modules(&mut self, enabled_modules: EnabledModules)
Sets the bit flags representing the enabled kernel modules.
Sourcepub fn enable_module(&mut self, module: EnabledModules)
pub fn enable_module(&mut self, module: EnabledModules)
Enables specific kernel module(s).
Sourcepub fn disable_module(&mut self, module: EnabledModules)
pub fn disable_module(&mut self, module: EnabledModules)
Disables specific kernel module(s).
Sourcepub fn with_component_state<S, N, F, O>(
&mut self,
node_id: N,
callback: F,
) -> Result<O, RuntimeError>
pub fn with_component_state<S, N, F, O>( &mut self, node_id: N, callback: F, ) -> Result<O, RuntimeError>
Reads the state of a component and allows for a callback to be executed over the decoded state.
This method performs the steps needed to read the state of a component and then perform the various steps needed before the state can be read or used such as the locking, reading, and decoding of the substate and the various steps that need to be performed after the state is read such as unlocking the substate.
Users of this method are expected to pass in a callback function to operate over the state as this is the main way that this method ensures that references do not escape out of this method after the substate is closed.
§Arguments
node_id
: [N
] - The address of the component to read the state of. This is a generic type parameter that’s satisfied by any type that implementsInto<NodeId>
.callback
: [F
] - A callback function to call after the component state has been read and decoded into the type specified by the generic parameter [S
]. Anything returned from this callback is returned from this method unless an error happens after the callback is executed.
§Returns
Result<O, RuntimeError>
- The output of the callback function passed in or a runtime error if one of the steps failed.
§Panics
This method panics if the component state can not be decoded as the generic type parameter
[S
].
Sourcepub fn get_current_epoch(&mut self) -> Epoch
pub fn get_current_epoch(&mut self) -> Epoch
Gets the current epoch from the Consensus Manager.
Sourcepub fn set_current_epoch(&mut self, epoch: Epoch)
pub fn set_current_epoch(&mut self, epoch: Epoch)
Sets the current epoch.
Sourcepub fn get_current_time(&mut self) -> Instant
pub fn get_current_time(&mut self) -> Instant
Gets the current time stamp from the Consensus Manager.
pub fn set_current_time(&mut self, instant: Instant)
Trait Implementations§
Source§impl<D> SystemActorApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemActorApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn actor_get_blueprint_id(&mut self) -> Result<BlueprintId, RuntimeError>
fn actor_get_blueprint_id(&mut self) -> Result<BlueprintId, RuntimeError>
Source§fn actor_open_field(
&mut self,
object_handle: ActorStateHandle,
field: FieldIndex,
flags: LockFlags,
) -> Result<FieldHandle, RuntimeError>
fn actor_open_field( &mut self, object_handle: ActorStateHandle, field: FieldIndex, flags: LockFlags, ) -> Result<FieldHandle, RuntimeError>
Source§fn actor_is_feature_enabled(
&mut self,
object_handle: ActorStateHandle,
feature: &str,
) -> Result<bool, RuntimeError>
fn actor_is_feature_enabled( &mut self, object_handle: ActorStateHandle, feature: &str, ) -> Result<bool, RuntimeError>
Source§fn actor_get_node_id(
&mut self,
ref_handle: ActorRefHandle,
) -> Result<NodeId, RuntimeError>
fn actor_get_node_id( &mut self, ref_handle: ActorRefHandle, ) -> Result<NodeId, RuntimeError>
Source§fn actor_emit_event(
&mut self,
event_name: String,
event_data: Vec<u8>,
event_flags: EventFlags,
) -> Result<(), RuntimeError>
fn actor_emit_event( &mut self, event_name: String, event_data: Vec<u8>, event_flags: EventFlags, ) -> Result<(), RuntimeError>
Source§impl<D> SystemActorIndexApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemActorIndexApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn actor_index_insert(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
key: Vec<u8>,
buffer: Vec<u8>,
) -> Result<(), RuntimeError>
fn actor_index_insert( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, key: Vec<u8>, buffer: Vec<u8>, ) -> Result<(), RuntimeError>
Source§fn actor_index_remove(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
key: Vec<u8>,
) -> Result<Option<Vec<u8>>, RuntimeError>
fn actor_index_remove( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, key: Vec<u8>, ) -> Result<Option<Vec<u8>>, RuntimeError>
Source§fn actor_index_scan_keys(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
limit: u32,
) -> Result<Vec<Vec<u8>>, RuntimeError>
fn actor_index_scan_keys( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, limit: u32, ) -> Result<Vec<Vec<u8>>, RuntimeError>
Source§fn actor_index_drain(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
limit: u32,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>, RuntimeError>
fn actor_index_drain( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, limit: u32, ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, RuntimeError>
Source§fn actor_index_insert_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: K,
value: V,
) -> Result<(), E>where
K: ScryptoEncode,
V: ScryptoEncode,
fn actor_index_insert_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: K,
value: V,
) -> Result<(), E>where
K: ScryptoEncode,
V: ScryptoEncode,
Source§fn actor_index_remove_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: Vec<u8>,
) -> Result<Option<V>, E>where
V: ScryptoDecode,
fn actor_index_remove_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: Vec<u8>,
) -> Result<Option<V>, E>where
V: ScryptoDecode,
Source§fn actor_index_scan_keys_typed<K>(
&mut self,
object_handle: u32,
collection_index: u8,
limit: u32,
) -> Result<Vec<K>, E>where
K: ScryptoDecode,
fn actor_index_scan_keys_typed<K>(
&mut self,
object_handle: u32,
collection_index: u8,
limit: u32,
) -> Result<Vec<K>, E>where
K: ScryptoDecode,
Source§fn actor_index_drain_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
limit: u32,
) -> Result<Vec<(K, V)>, E>where
K: ScryptoDecode,
V: ScryptoDecode,
fn actor_index_drain_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
limit: u32,
) -> Result<Vec<(K, V)>, E>where
K: ScryptoDecode,
V: ScryptoDecode,
Source§impl<D> SystemActorKeyValueEntryApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemActorKeyValueEntryApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn actor_open_key_value_entry(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
key: &Vec<u8>,
flags: LockFlags,
) -> Result<KeyValueEntryHandle, RuntimeError>
fn actor_open_key_value_entry( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, key: &Vec<u8>, flags: LockFlags, ) -> Result<KeyValueEntryHandle, RuntimeError>
Source§fn actor_remove_key_value_entry(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
key: &Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn actor_remove_key_value_entry( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, key: &Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§fn actor_remove_key_value_entry_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: &Vec<u8>,
) -> Result<Option<V>, E>where
V: ScryptoDecode,
fn actor_remove_key_value_entry_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
key: &Vec<u8>,
) -> Result<Option<V>, E>where
V: ScryptoDecode,
Source§impl<D> SystemActorSortedIndexApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemActorSortedIndexApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn actor_sorted_index_insert(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
sorted_key: SortedKey,
buffer: Vec<u8>,
) -> Result<(), RuntimeError>
fn actor_sorted_index_insert( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, sorted_key: SortedKey, buffer: Vec<u8>, ) -> Result<(), RuntimeError>
Source§fn actor_sorted_index_remove(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
sorted_key: &SortedKey,
) -> Result<Option<Vec<u8>>, RuntimeError>
fn actor_sorted_index_remove( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, sorted_key: &SortedKey, ) -> Result<Option<Vec<u8>>, RuntimeError>
Source§fn actor_sorted_index_scan(
&mut self,
object_handle: ActorStateHandle,
collection_index: CollectionIndex,
count: u32,
) -> Result<Vec<(SortedKey, Vec<u8>)>, RuntimeError>
fn actor_sorted_index_scan( &mut self, object_handle: ActorStateHandle, collection_index: CollectionIndex, count: u32, ) -> Result<Vec<(SortedKey, Vec<u8>)>, RuntimeError>
Source§fn actor_sorted_index_insert_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
sorted_key: ([u8; 2], Vec<u8>),
value: V,
) -> Result<(), E>where
V: ScryptoEncode,
fn actor_sorted_index_insert_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
sorted_key: ([u8; 2], Vec<u8>),
value: V,
) -> Result<(), E>where
V: ScryptoEncode,
Source§fn actor_sorted_index_remove_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
sorted_key: &([u8; 2], Vec<u8>),
) -> Result<Option<V>, E>where
V: ScryptoDecode,
fn actor_sorted_index_remove_typed<V>(
&mut self,
object_handle: u32,
collection_index: u8,
sorted_key: &([u8; 2], Vec<u8>),
) -> Result<Option<V>, E>where
V: ScryptoDecode,
Source§fn actor_sorted_index_scan_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
count: u32,
) -> Result<Vec<(K, V)>, E>where
K: ScryptoDecode,
V: ScryptoDecode,
fn actor_sorted_index_scan_typed<K, V>(
&mut self,
object_handle: u32,
collection_index: u8,
count: u32,
) -> Result<Vec<(K, V)>, E>where
K: ScryptoDecode,
V: ScryptoDecode,
Source§impl<D> SystemBlueprintApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemBlueprintApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn call_function(
&mut self,
package_address: PackageAddress,
blueprint_name: &str,
function_name: &str,
args: Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn call_function( &mut self, package_address: PackageAddress, blueprint_name: &str, function_name: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§fn resolve_blueprint_type(
&mut self,
blueprint_type_id: &BlueprintTypeIdentifier,
) -> Result<(Rc<VersionedScryptoSchema>, ScopedTypeId), RuntimeError>
fn resolve_blueprint_type( &mut self, blueprint_type_id: &BlueprintTypeIdentifier, ) -> Result<(Rc<VersionedScryptoSchema>, ScopedTypeId), RuntimeError>
Source§impl<D> SystemCostingApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemCostingApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn start_lock_fee(
&mut self,
amount: Decimal,
contingent: bool,
) -> Result<bool, RuntimeError>
fn start_lock_fee( &mut self, amount: Decimal, contingent: bool, ) -> Result<bool, RuntimeError>
Source§fn lock_fee(&mut self, locked_fee: LiquidFungibleResource, contingent: bool)
fn lock_fee(&mut self, locked_fee: LiquidFungibleResource, contingent: bool)
Source§fn consume_cost_units(
&mut self,
costing_entry: ClientCostingEntry<'_>,
) -> Result<(), RuntimeError>
fn consume_cost_units( &mut self, costing_entry: ClientCostingEntry<'_>, ) -> Result<(), RuntimeError>
Source§fn execution_cost_unit_limit(&mut self) -> Result<u32, RuntimeError>
fn execution_cost_unit_limit(&mut self) -> Result<u32, RuntimeError>
Source§fn execution_cost_unit_price(&mut self) -> Result<Decimal, RuntimeError>
fn execution_cost_unit_price(&mut self) -> Result<Decimal, RuntimeError>
Source§fn finalization_cost_unit_limit(&mut self) -> Result<u32, RuntimeError>
fn finalization_cost_unit_limit(&mut self) -> Result<u32, RuntimeError>
Source§fn finalization_cost_unit_price(&mut self) -> Result<Decimal, RuntimeError>
fn finalization_cost_unit_price(&mut self) -> Result<Decimal, RuntimeError>
Source§fn max_per_function_royalty_in_xrd(&mut self) -> Result<Decimal, RuntimeError>
fn max_per_function_royalty_in_xrd(&mut self) -> Result<Decimal, RuntimeError>
Source§fn tip_percentage_truncated(&mut self) -> Result<u32, RuntimeError>
fn tip_percentage_truncated(&mut self) -> Result<u32, RuntimeError>
Source§fn fee_balance(&mut self) -> Result<Decimal, RuntimeError>
fn fee_balance(&mut self) -> Result<Decimal, RuntimeError>
Source§impl<D> SystemExecutionTraceApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemExecutionTraceApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
fn update_instruction_index( &mut self, new_index: usize, ) -> Result<(), RuntimeError>
Source§impl<D> SystemFieldApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemFieldApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn field_read(&mut self, handle: FieldHandle) -> Result<Vec<u8>, RuntimeError>
fn field_read(&mut self, handle: FieldHandle) -> Result<Vec<u8>, RuntimeError>
Source§fn field_write(
&mut self,
handle: FieldHandle,
buffer: Vec<u8>,
) -> Result<(), RuntimeError>
fn field_write( &mut self, handle: FieldHandle, buffer: Vec<u8>, ) -> Result<(), RuntimeError>
Source§fn field_lock(&mut self, handle: FieldHandle) -> Result<(), RuntimeError>
fn field_lock(&mut self, handle: FieldHandle) -> Result<(), RuntimeError>
Source§fn field_close(&mut self, handle: FieldHandle) -> Result<(), RuntimeError>
fn field_close(&mut self, handle: FieldHandle) -> Result<(), RuntimeError>
Source§fn field_read_typed<S>(&mut self, handle: u32) -> Result<S, E>where
S: ScryptoDecode,
fn field_read_typed<S>(&mut self, handle: u32) -> Result<S, E>where
S: ScryptoDecode,
Source§fn field_write_typed<S>(&mut self, handle: u32, substate: &S) -> Result<(), E>where
S: ScryptoEncode,
fn field_write_typed<S>(&mut self, handle: u32, substate: &S) -> Result<(), E>where
S: ScryptoEncode,
Source§impl<D> SystemKeyValueEntryApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemKeyValueEntryApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn key_value_entry_get(
&mut self,
handle: KeyValueEntryHandle,
) -> Result<Vec<u8>, RuntimeError>
fn key_value_entry_get( &mut self, handle: KeyValueEntryHandle, ) -> Result<Vec<u8>, RuntimeError>
Source§fn key_value_entry_set(
&mut self,
handle: KeyValueEntryHandle,
buffer: Vec<u8>,
) -> Result<(), RuntimeError>
fn key_value_entry_set( &mut self, handle: KeyValueEntryHandle, buffer: Vec<u8>, ) -> Result<(), RuntimeError>
Source§fn key_value_entry_remove(
&mut self,
handle: KeyValueEntryHandle,
) -> Result<Vec<u8>, RuntimeError>
fn key_value_entry_remove( &mut self, handle: KeyValueEntryHandle, ) -> Result<Vec<u8>, RuntimeError>
Source§fn key_value_entry_lock(
&mut self,
handle: KeyValueEntryHandle,
) -> Result<(), RuntimeError>
fn key_value_entry_lock( &mut self, handle: KeyValueEntryHandle, ) -> Result<(), RuntimeError>
Source§fn key_value_entry_close(
&mut self,
handle: KeyValueEntryHandle,
) -> Result<(), RuntimeError>
fn key_value_entry_close( &mut self, handle: KeyValueEntryHandle, ) -> Result<(), RuntimeError>
Source§fn key_value_entry_get_typed<S>(&mut self, handle: u32) -> Result<Option<S>, E>where
S: ScryptoDecode,
fn key_value_entry_get_typed<S>(&mut self, handle: u32) -> Result<Option<S>, E>where
S: ScryptoDecode,
Source§fn key_value_entry_set_typed<S>(
&mut self,
handle: u32,
value: S,
) -> Result<(), E>where
S: ScryptoEncode,
fn key_value_entry_set_typed<S>(
&mut self,
handle: u32,
value: S,
) -> Result<(), E>where
S: ScryptoEncode,
Source§impl<D> SystemKeyValueStoreApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemKeyValueStoreApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn key_value_store_new(
&mut self,
data_schema: KeyValueStoreDataSchema,
) -> Result<NodeId, RuntimeError>
fn key_value_store_new( &mut self, data_schema: KeyValueStoreDataSchema, ) -> Result<NodeId, RuntimeError>
Source§fn key_value_store_open_entry(
&mut self,
node_id: &NodeId,
key: &Vec<u8>,
flags: LockFlags,
) -> Result<KeyValueEntryHandle, RuntimeError>
fn key_value_store_open_entry( &mut self, node_id: &NodeId, key: &Vec<u8>, flags: LockFlags, ) -> Result<KeyValueEntryHandle, RuntimeError>
Source§fn key_value_store_remove_entry(
&mut self,
node_id: &NodeId,
key: &Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn key_value_store_remove_entry( &mut self, node_id: &NodeId, key: &Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§impl<D> SystemObjectApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemObjectApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn new_object(
&mut self,
blueprint_ident: &str,
features: Vec<&str>,
generic_args: GenericArgs,
fields: IndexMap<FieldIndex, FieldValue>,
kv_entries: IndexMap<u8, IndexMap<Vec<u8>, KVEntry>>,
) -> Result<NodeId, RuntimeError>
fn new_object( &mut self, blueprint_ident: &str, features: Vec<&str>, generic_args: GenericArgs, fields: IndexMap<FieldIndex, FieldValue>, kv_entries: IndexMap<u8, IndexMap<Vec<u8>, KVEntry>>, ) -> Result<NodeId, RuntimeError>
Source§fn drop_object(
&mut self,
node_id: &NodeId,
) -> Result<Vec<Vec<u8>>, RuntimeError>
fn drop_object( &mut self, node_id: &NodeId, ) -> Result<Vec<Vec<u8>>, RuntimeError>
Source§fn get_blueprint_id(
&mut self,
node_id: &NodeId,
) -> Result<BlueprintId, RuntimeError>
fn get_blueprint_id( &mut self, node_id: &NodeId, ) -> Result<BlueprintId, RuntimeError>
Source§fn get_outer_object(
&mut self,
node_id: &NodeId,
) -> Result<GlobalAddress, RuntimeError>
fn get_outer_object( &mut self, node_id: &NodeId, ) -> Result<GlobalAddress, RuntimeError>
Source§fn allocate_global_address(
&mut self,
blueprint_id: BlueprintId,
) -> Result<(GlobalAddressReservation, GlobalAddress), RuntimeError>
fn allocate_global_address( &mut self, blueprint_id: BlueprintId, ) -> Result<(GlobalAddressReservation, GlobalAddress), RuntimeError>
Source§fn allocate_virtual_global_address(
&mut self,
blueprint_id: BlueprintId,
global_address: GlobalAddress,
) -> Result<GlobalAddressReservation, RuntimeError>
fn allocate_virtual_global_address( &mut self, blueprint_id: BlueprintId, global_address: GlobalAddress, ) -> Result<GlobalAddressReservation, RuntimeError>
Source§fn get_reservation_address(
&mut self,
node_id: &NodeId,
) -> Result<GlobalAddress, RuntimeError>
fn get_reservation_address( &mut self, node_id: &NodeId, ) -> Result<GlobalAddress, RuntimeError>
Source§fn globalize(
&mut self,
node_id: NodeId,
modules: IndexMap<AttachedModuleId, NodeId>,
address_reservation: Option<GlobalAddressReservation>,
) -> Result<GlobalAddress, RuntimeError>
fn globalize( &mut self, node_id: NodeId, modules: IndexMap<AttachedModuleId, NodeId>, address_reservation: Option<GlobalAddressReservation>, ) -> Result<GlobalAddress, RuntimeError>
Source§fn globalize_with_address_and_create_inner_object_and_emit_event(
&mut self,
node_id: NodeId,
modules: IndexMap<AttachedModuleId, NodeId>,
address_reservation: GlobalAddressReservation,
inner_object_blueprint: &str,
inner_object_fields: IndexMap<u8, FieldValue>,
event_name: &str,
event_data: Vec<u8>,
) -> Result<(GlobalAddress, NodeId), RuntimeError>
fn globalize_with_address_and_create_inner_object_and_emit_event( &mut self, node_id: NodeId, modules: IndexMap<AttachedModuleId, NodeId>, address_reservation: GlobalAddressReservation, inner_object_blueprint: &str, inner_object_fields: IndexMap<u8, FieldValue>, event_name: &str, event_data: Vec<u8>, ) -> Result<(GlobalAddress, NodeId), RuntimeError>
Source§fn call_method(
&mut self,
receiver: &NodeId,
method_name: &str,
args: Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn call_method( &mut self, receiver: &NodeId, method_name: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§fn call_direct_access_method(
&mut self,
receiver: &NodeId,
method_name: &str,
args: Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn call_direct_access_method( &mut self, receiver: &NodeId, method_name: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§fn call_module_method(
&mut self,
receiver: &NodeId,
module_id: AttachedModuleId,
method_name: &str,
args: Vec<u8>,
) -> Result<Vec<u8>, RuntimeError>
fn call_module_method( &mut self, receiver: &NodeId, module_id: AttachedModuleId, method_name: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>
Source§fn new_simple_object(
&mut self,
blueprint_ident: &str,
fields: IndexMap<u8, FieldValue>,
) -> Result<NodeId, E>
fn new_simple_object( &mut self, blueprint_ident: &str, fields: IndexMap<u8, FieldValue>, ) -> Result<NodeId, E>
Source§impl<D> SystemTransactionRuntimeApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
impl<D> SystemTransactionRuntimeApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Source§fn bech32_encode_address(
&mut self,
address: GlobalAddress,
) -> Result<String, RuntimeError>
fn bech32_encode_address( &mut self, address: GlobalAddress, ) -> Result<String, RuntimeError>
Source§fn get_transaction_hash(&mut self) -> Result<Hash, RuntimeError>
fn get_transaction_hash(&mut self) -> Result<Hash, RuntimeError>
Source§fn generate_ruid(&mut self) -> Result<[u8; 32], RuntimeError>
fn generate_ruid(&mut self) -> Result<[u8; 32], RuntimeError>
impl<D> SystemApi<RuntimeError> for TestEnvironment<D>where
D: SubstateDatabase + CommittableSubstateDatabase + 'static,
Auto Trait Implementations§
impl<D> Freeze for TestEnvironment<D>
impl<D> !RefUnwindSafe for TestEnvironment<D>
impl<D> !Send for TestEnvironment<D>
impl<D> !Sync for TestEnvironment<D>
impl<D> Unpin for TestEnvironment<D>
impl<D> !UnwindSafe for TestEnvironment<D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
type Error = <U as ContextualTryFrom<T>>::Error
type Context = <U as ContextualTryFrom<T>>::Context
fn contextual_try_into( self, context: &<U as ContextualTryFrom<T>>::Context, ) -> Result<U, <U as ContextualTryFrom<T>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more