pub struct Env { /* private fields */ }
Expand description
Implementations§
Source§impl Env
impl Env
Sourcepub fn storage(&self) -> Storage
pub fn storage(&self) -> Storage
Get a Storage for accessing and updating persistent data owned by the currently executing contract.
Sourcepub fn events(&self) -> Events
pub fn events(&self) -> Events
Get Events for publishing events associated with the currently executing contract.
Sourcepub fn crypto_hazmat(&self) -> CryptoHazmat
Available on crate feature hazmat
only.
pub fn crypto_hazmat(&self) -> CryptoHazmat
hazmat
only.§⚠️ Hazardous Materials
Get a CryptoHazmat for accessing the cryptographic functions that are not generally recommended. Using them incorrectly can introduce security vulnerabilities. Use Crypto if possible.
Sourcepub fn current_contract_address(&self) -> Address
pub fn current_contract_address(&self) -> Address
Get the Address object corresponding to the current executing contract.
Sourcepub fn invoke_contract<T>(
&self,
contract_address: &Address,
func: &Symbol,
args: Vec<Val>,
) -> T
pub fn invoke_contract<T>( &self, contract_address: &Address, func: &Symbol, args: Vec<Val>, ) -> T
Invokes a function of a contract that is registered in the Env.
§Panics
Will panic if the contract_id
does not match a registered contract,
func
does not match a function of the referenced contract, or the
number of args
do not match the argument count of the referenced
contract function.
Will panic if the contract that is invoked fails or aborts in anyway.
Will panic if the value returned from the contract cannot be converted
into the type T
.
Sourcepub fn try_invoke_contract<T, E>(
&self,
contract_address: &Address,
func: &Symbol,
args: Vec<Val>,
) -> Result<Result<T, T::Error>, Result<E, InvokeError>>
pub fn try_invoke_contract<T, E>( &self, contract_address: &Address, func: &Symbol, args: Vec<Val>, ) -> Result<Result<T, T::Error>, Result<E, InvokeError>>
Invokes a function of a contract that is registered in the Env, returns an error if the invocation fails for any reason.
Authorizes sub-contract calls on behalf of the current contract.
All the direct calls that the current contract performs are always considered to have been authorized. This is only needed to authorize deeper calls that originate from the next contract call from the current contract.
For example, if the contract A calls contract B, contract
B calls contract C and contract C calls A.require_auth()
, then an
entry corresponding to C call has to be passed in auth_entries
. It
doesn’t matter if contract B called require_auth
or not. If contract A
calls contract B again, then authorize_as_current_contract
has to be
called again with the respective entries.
Source§impl Env
impl Env
Sourcepub fn new_with_config(config: EnvTestConfig) -> Env
Available on crate feature testutils
only.
pub fn new_with_config(config: EnvTestConfig) -> Env
testutils
only.Create an Env with the test config.
Sourcepub fn set_config(&mut self, config: EnvTestConfig)
Available on crate feature testutils
only.
pub fn set_config(&mut self, config: EnvTestConfig)
testutils
only.Change the test config of an Env.
Sourcepub fn cost_estimate(&self) -> CostEstimate
Available on crate feature testutils
only.
pub fn cost_estimate(&self) -> CostEstimate
testutils
only.Returns the resources metered during the last top level contract invocation.
In order to get non-None
results, enable_invocation_metering
has to
be called and at least one invocation has to happen after that.
Take the return value with a grain of salt. The returned resources mostly correspond only to the operations that have happened during the host invocation, i.e. this won’t try to simulate the work that happens in production scenarios (e.g. certain XDR rountrips). This also doesn’t try to model resources related to the transaction size.
The returned value is as useful as the preceding setup, e.g. if a test contract is used instead of a Wasm contract, all the costs related to VM instantiation and execution, as well as Wasm reads/rent bumps will be missed.
While the resource metering may be useful for contract optimization, keep in mind that resource and fee estimation may be imprecise. Use simulation with RPC in order to get the exact resources for submitting the transactions to the network.
Sourcepub fn register<'a, C, A>(&self, contract: C, constructor_args: A) -> Addresswhere
C: Register,
A: ConstructorArgs,
Available on crate feature testutils
only.
pub fn register<'a, C, A>(&self, contract: C, constructor_args: A) -> Addresswhere
C: Register,
A: ConstructorArgs,
testutils
only.Register a contract with the Env for testing.
Pass the contract type when the contract is defined in the current crate and is being registered natively. Pass the contract wasm bytes when the contract has been loaded as wasm.
Pass the arguments for the contract’s constructor, or ()
if none. For
contracts with a constructor, use the contract’s generated Args
type
to construct the arguments with the appropropriate types for invoking
the constructor during registration.
Returns the address of the registered contract that is the same as the contract id passed in.
If you need to specify the address the contract should be registered at,
use Env::register_at
.
§Examples
Register a contract defined in the current crate, by specifying the type name:
use soroban_sdk::{contract, contractimpl, testutils::Address as _, Address, BytesN, Env, Symbol};
#[contract]
pub struct Contract;
#[contractimpl]
impl Contract {
pub fn __constructor(_env: Env, _input: u32) {
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register(Contract, ContractArgs::__constructor(&123,));
}
Register a contract wasm, by specifying the wasm bytes:
use soroban_sdk::{testutils::Address as _, Address, BytesN, Env};
const WASM: &[u8] = include_bytes!("../doctest_fixtures/contract.wasm");
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register(WASM, ());
}
Sourcepub fn register_at<C, A>(
&self,
contract_id: &Address,
contract: C,
constructor_args: A,
) -> Addresswhere
C: Register,
A: ConstructorArgs,
Available on crate feature testutils
only.
pub fn register_at<C, A>(
&self,
contract_id: &Address,
contract: C,
constructor_args: A,
) -> Addresswhere
C: Register,
A: ConstructorArgs,
testutils
only.Register a contract with the Env for testing.
Passing a contract ID for the first arguments registers the contract with that contract ID.
Registering a contract that is already registered replaces it. Use re-registration with caution as it does not exist in the real (on-chain) environment. Specifically, the new contract’s constructor will be called again during re-registration. That behavior only exists for this test utility and is not reproducible on-chain, where contract Wasm updates don’t cause constructor to be called.
Pass the contract type when the contract is defined in the current crate and is being registered natively. Pass the contract wasm bytes when the contract has been loaded as wasm.
Returns the address of the registered contract that is the same as the contract id passed in.
§Examples
Register a contract defined in the current crate, by specifying the type name:
use soroban_sdk::{contract, contractimpl, testutils::Address as _, Address, BytesN, Env, Symbol};
#[contract]
pub struct Contract;
#[contractimpl]
impl Contract {
pub fn __constructor(_env: Env, _input: u32) {
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = Address::generate(&env);
env.register_at(&contract_id, Contract, (123_u32,));
}
Register a contract wasm, by specifying the wasm bytes:
use soroban_sdk::{testutils::Address as _, Address, BytesN, Env};
const WASM: &[u8] = include_bytes!("../doctest_fixtures/contract.wasm");
#[test]
fn test() {
let env = Env::default();
let contract_id = Address::generate(&env);
env.register_at(&contract_id, WASM, ());
}
Sourcepub fn register_contract<'a, T: ContractFunctionSet + 'static>(
&self,
contract_id: impl Into<Option<&'a Address>>,
contract: T,
) -> Address
👎Deprecated: use register
Available on crate feature testutils
only.
pub fn register_contract<'a, T: ContractFunctionSet + 'static>( &self, contract_id: impl Into<Option<&'a Address>>, contract: T, ) -> Address
register
testutils
only.Register a contract with the Env for testing.
Passing a contract ID for the first arguments registers the contract
with that contract ID. Providing None
causes the Env to generate a new
contract ID that is assigned to the contract.
If a contract has a constructor defined, then it will be called with
no arguments. If a constructor takes arguments, use register
.
Registering a contract that is already registered replaces it. Use re-registration with caution as it does not exist in the real (on-chain) environment. Specifically, the new contract’s constructor will be called again during re-registration. That behavior only exists for this test utility and is not reproducible on-chain, where contract Wasm updates don’t cause constructor to be called.
Returns the address of the registered contract.
§Examples
use soroban_sdk::{contract, contractimpl, BytesN, Env, Symbol};
#[contract]
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, recipient: Symbol) -> Symbol {
todo!()
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register_contract(None, HelloContract);
}
Sourcepub fn register_contract_wasm<'a>(
&self,
contract_id: impl Into<Option<&'a Address>>,
contract_wasm: impl IntoVal<Env, Bytes>,
) -> Address
👎Deprecated: use register
Available on crate feature testutils
only.
pub fn register_contract_wasm<'a>( &self, contract_id: impl Into<Option<&'a Address>>, contract_wasm: impl IntoVal<Env, Bytes>, ) -> Address
register
testutils
only.Register a contract in a Wasm file with the Env for testing.
Passing a contract ID for the first arguments registers the contract
with that contract ID. Providing None
causes the Env to generate a new
contract ID that is assigned to the contract.
Registering a contract that is already registered replaces it. Use re-registration with caution as it does not exist in the real (on-chain) environment. Specifically, the new contract’s constructor will be called again during re-registration. That behavior only exists for this test utility and is not reproducible on-chain, where contract Wasm updates don’t cause constructor to be called.
Returns the address of the registered contract.
§Examples
use soroban_sdk::{BytesN, Env};
const WASM: &[u8] = include_bytes!("../doctest_fixtures/contract.wasm");
#[test]
fn test() {
let env = Env::default();
env.register_contract_wasm(None, WASM);
}
Sourcepub fn register_stellar_asset_contract_v2(
&self,
admin: Address,
) -> StellarAssetContract
Available on crate feature testutils
only.
pub fn register_stellar_asset_contract_v2( &self, admin: Address, ) -> StellarAssetContract
testutils
only.Register the built-in Stellar Asset Contract with provided admin address.
Returns a utility struct that contains the contract ID of the registered token contract, as well as methods to read and update issuer flags.
The contract will wrap a randomly-generated Stellar asset. This function is useful for using in the tests when an arbitrary token contract instance is needed.
Sourcepub fn register_stellar_asset_contract(&self, admin: Address) -> Address
👎Deprecated: use [Env::register_stellar_asset_contract_v2]Available on crate feature testutils
only.
pub fn register_stellar_asset_contract(&self, admin: Address) -> Address
testutils
only.Register the built-in Stellar Asset Contract with provided admin address.
Returns the contract ID of the registered token contract.
The contract will wrap a randomly-generated Stellar asset. This function is useful for using in the tests when an arbitrary token contract instance is needed.
Sourcepub fn set_auths(&self, auths: &[SorobanAuthorizationEntry])
Available on crate feature testutils
only.
pub fn set_auths(&self, auths: &[SorobanAuthorizationEntry])
testutils
only.Set authorizations and signatures in the environment which will be
consumed by contracts when they invoke Address::require_auth
or
Address::require_auth_for_args
functions.
Requires valid signatures for the authorization to be successful.
This function can also be called on contract clients.
To mock auth for testing, without requiring valid signatures, use
mock_all_auths
or
mock_auths
. If mocking of auths is enabled,
calling set_auths
disables any mocking.
Sourcepub fn mock_auths(&self, auths: &[MockAuth<'_>])
Available on crate feature testutils
only.
pub fn mock_auths(&self, auths: &[MockAuth<'_>])
testutils
only.Mock authorizations in the environment which will cause matching invokes
of Address::require_auth
and Address::require_auth_for_args
to
pass.
This function can also be called on contract clients.
Authorizations not matching a mocked auth will fail.
To mock all auths, use mock_all_auths
.
§Examples
use soroban_sdk::{contract, contractimpl, Env, Address, testutils::{Address as _, MockAuth, MockAuthInvoke}, IntoVal};
#[contract]
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, from: Address) {
from.require_auth();
// TODO
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register(HelloContract, ());
let client = HelloContractClient::new(&env, &contract_id);
let addr = Address::generate(&env);
client.mock_auths(&[
MockAuth {
address: &addr,
invoke: &MockAuthInvoke {
contract: &contract_id,
fn_name: "hello",
args: (&addr,).into_val(&env),
sub_invokes: &[],
},
},
]).hello(&addr);
}
Sourcepub fn mock_all_auths(&self)
Available on crate feature testutils
only.
pub fn mock_all_auths(&self)
testutils
only.Mock all calls to the Address::require_auth
and
Address::require_auth_for_args
functions in invoked contracts,
having them succeed as if authorization was provided.
When mocking is enabled, if the Address
being authorized is the
address of a contract, that contract’s __check_auth
function will not
be called, and the contract does not need to exist or be registered in
the test.
When mocking is enabled, if the Address
being authorized is the
address of an account, the account does not need to exist.
This function can also be called on contract clients.
To disable mocking, see set_auths
.
To access a list of auths that have occurred, see auths
.
It is not currently possible to mock a subset of auths.
§Examples
use soroban_sdk::{contract, contractimpl, Env, Address, testutils::Address as _};
#[contract]
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, from: Address) {
from.require_auth();
// TODO
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = env.register(HelloContract, ());
env.mock_all_auths();
let client = HelloContractClient::new(&env, &contract_id);
let addr = Address::generate(&env);
client.hello(&addr);
}
Sourcepub fn mock_all_auths_allowing_non_root_auth(&self)
Available on crate feature testutils
only.
pub fn mock_all_auths_allowing_non_root_auth(&self)
testutils
only.A version of mock_all_auths
that allows authorizations that are not
present in the root invocation.
Refer to mock_all_auths
documentation for general information and
prefer using mock_all_auths
unless non-root authorization is required.
The only difference from mock_all_auths
is that this won’t return an
error when require_auth
hasn’t been called in the root invocation for
any given address. This is useful to test contracts that bundle calls to
another contract without atomicity requirements (i.e. any contract call
can be frontrun).
§Examples
use soroban_sdk::{contract, contractimpl, Env, Address, testutils::Address as _};
#[contract]
pub struct ContractA;
#[contractimpl]
impl ContractA {
pub fn do_auth(env: Env, addr: Address) {
addr.require_auth();
}
}
#[contract]
pub struct ContractB;
#[contractimpl]
impl ContractB {
pub fn call_a(env: Env, contract_a: Address, addr: Address) {
// Notice there is no `require_auth` call here.
ContractAClient::new(&env, &contract_a).do_auth(&addr);
}
}
#[test]
fn test() {
let env = Env::default();
let contract_a = env.register(ContractA, ());
let contract_b = env.register(ContractB, ());
// The regular `env.mock_all_auths()` would result in the call
// failure.
env.mock_all_auths_allowing_non_root_auth();
let client = ContractBClient::new(&env, &contract_b);
let addr = Address::generate(&env);
client.call_a(&contract_a, &addr);
}
Sourcepub fn auths(&self) -> Vec<(Address, AuthorizedInvocation)>
Available on crate feature testutils
only.
pub fn auths(&self) -> Vec<(Address, AuthorizedInvocation)>
testutils
only.Returns a list of authorization trees that were seen during the last contract or authorized host function invocation.
Use this in tests to verify that the expected authorizations with the expected arguments are required.
The return value is a vector of authorizations represented by tuples of
(address, AuthorizedInvocation)
. AuthorizedInvocation
describes the
tree of require_auth_for_args(address, args)
from the contract
functions (or require_auth
with all the arguments of the function
invocation). It also might contain the authorized host functions (
currently CreateContract is the only such function) in case if
corresponding host functions have been called.
Refer to documentation for AuthorizedInvocation
for detailed
information on its contents.
The order of the returned vector is defined by the order of
Address::require_auth
calls. Repeated calls to
Address::require_auth
with the same address and args in the same
tree of contract invocations will appear only once in the vector.
§Examples
use soroban_sdk::{contract, contractimpl, testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, symbol_short, Address, Symbol, Env, IntoVal};
#[contract]
pub struct Contract;
#[contractimpl]
impl Contract {
pub fn transfer(env: Env, address: Address, amount: i128) {
address.require_auth();
}
pub fn transfer2(env: Env, address: Address, amount: i128) {
address.require_auth_for_args((amount / 2,).into_val(&env));
}
}
#[test]
fn test() {
extern crate std;
let env = Env::default();
let contract_id = env.register(Contract, ());
let client = ContractClient::new(&env, &contract_id);
env.mock_all_auths();
let address = Address::generate(&env);
client.transfer(&address, &1000_i128);
assert_eq!(
env.auths(),
std::vec![(
address.clone(),
AuthorizedInvocation {
function: AuthorizedFunction::Contract((
client.address.clone(),
symbol_short!("transfer"),
(&address, 1000_i128,).into_val(&env)
)),
sub_invocations: std::vec![]
}
)]
);
client.transfer2(&address, &1000_i128);
assert_eq!(
env.auths(),
std::vec![(
address.clone(),
AuthorizedInvocation {
function: AuthorizedFunction::Contract((
client.address.clone(),
symbol_short!("transfer2"),
// `transfer2` requires auth for (amount / 2) == (1000 / 2) == 500.
(500_i128,).into_val(&env)
)),
sub_invocations: std::vec![]
}
)]
);
}
Sourcepub fn try_invoke_contract_check_auth<E>(
&self,
contract: &Address,
signature_payload: &BytesN<32>,
signature: Val,
auth_context: &Vec<Context>,
) -> Result<(), Result<E, InvokeError>>
Available on crate feature testutils
only.
pub fn try_invoke_contract_check_auth<E>( &self, contract: &Address, signature_payload: &BytesN<32>, signature: Val, auth_context: &Vec<Context>, ) -> Result<(), Result<E, InvokeError>>
testutils
only.Invokes the special __check_auth
function of contracts that implement
the custom account interface.
__check_auth
can’t be called outside of the host-managed require_auth
calls. This test utility allows testing custom account contracts without
the need to setup complex contract call trees and enabling the enforcing
auth on the host side.
This function requires to provide the template argument for error. Use
soroban_sdk::Error
if __check_auth
doesn’t return a special
contract error and use the error with contracterror
attribute
otherwise.
§Examples
use soroban_sdk::{contract, contracterror, contractimpl, testutils::{Address as _, BytesN as _}, vec, auth::Context, BytesN, Env, Vec, Val};
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum NoopAccountError {
SomeError = 1,
}
#[contract]
struct NoopAccountContract;
#[contractimpl]
impl NoopAccountContract {
#[allow(non_snake_case)]
pub fn __check_auth(
_env: Env,
_signature_payload: BytesN<32>,
signature: Val,
_auth_context: Vec<Context>,
) -> Result<(), NoopAccountError> {
if signature.is_void() {
Err(NoopAccountError::SomeError)
} else {
Ok(())
}
}
}
#[test]
fn test() {
let e: Env = Default::default();
let account_contract = NoopAccountContractClient::new(&e, &e.register(NoopAccountContract, ()));
// Non-succesful call of `__check_auth` with a `contracterror` error.
assert_eq!(
e.try_invoke_contract_check_auth::<NoopAccountError>(
&account_contract.address,
&BytesN::from_array(&e, &[0; 32]),
().into(),
&vec![&e],
),
// The inner `Result` is for conversion error and will be Ok
// as long as a valid error type used.
Err(Ok(NoopAccountError::SomeError))
);
// Successful call of `__check_auth` with a `soroban_sdk::InvokeError`
// error - this should be compatible with any error type.
assert_eq!(
e.try_invoke_contract_check_auth::<soroban_sdk::InvokeError>(
&account_contract.address,
&BytesN::from_array(&e, &[0; 32]),
0_i32.into(),
&vec![&e],
),
Ok(())
);
}
Sourcepub fn as_contract<T>(&self, id: &Address, f: impl FnOnce() -> T) -> T
Available on crate feature testutils
only.
pub fn as_contract<T>(&self, id: &Address, f: impl FnOnce() -> T) -> T
testutils
only.Run the function as if executed by the given contract ID.
Used to write or read contract data, or take other actions in tests for setting up tests or asserting on internal state.
Sourcepub fn from_snapshot(s: Snapshot) -> Env
Available on crate feature testutils
only.
pub fn from_snapshot(s: Snapshot) -> Env
testutils
only.Creates a new Env loaded with the Snapshot
.
The ledger info and state in the snapshot are loaded into the Env.
Events, as an output source only, are not loaded into the Env.
Sourcepub fn from_snapshot_file(p: impl AsRef<Path>) -> Env
Available on crate feature testutils
only.
pub fn from_snapshot_file(p: impl AsRef<Path>) -> Env
testutils
only.Creates a new Env loaded with the ledger snapshot loaded from the file.
The ledger info and state in the snapshot are loaded into the Env.
Events, as an output source only, are not loaded into the Env.
§Panics
If there is any error reading the file.
Sourcepub fn to_snapshot(&self) -> Snapshot
Available on crate feature testutils
only.
pub fn to_snapshot(&self) -> Snapshot
testutils
only.Create a snapshot from the Env’s current state.
Sourcepub fn to_snapshot_file(&self, p: impl AsRef<Path>)
Available on crate feature testutils
only.
pub fn to_snapshot_file(&self, p: impl AsRef<Path>)
testutils
only.Create a snapshot file from the Env’s current state.
§Panics
If there is any error writing the file.
Sourcepub fn from_ledger_snapshot(s: LedgerSnapshot) -> Env
Available on crate feature testutils
only.
pub fn from_ledger_snapshot(s: LedgerSnapshot) -> Env
testutils
only.Creates a new Env loaded with the LedgerSnapshot
.
The ledger info and state in the snapshot are loaded into the Env.
Sourcepub fn from_ledger_snapshot_file(p: impl AsRef<Path>) -> Env
Available on crate feature testutils
only.
pub fn from_ledger_snapshot_file(p: impl AsRef<Path>) -> Env
testutils
only.Creates a new Env loaded with the ledger snapshot loaded from the file.
§Panics
If there is any error reading the file.
Sourcepub fn to_ledger_snapshot(&self) -> LedgerSnapshot
Available on crate feature testutils
only.
pub fn to_ledger_snapshot(&self) -> LedgerSnapshot
testutils
only.Create a snapshot from the Env’s current state.
Sourcepub fn to_ledger_snapshot_file(&self, p: impl AsRef<Path>)
Available on crate feature testutils
only.
pub fn to_ledger_snapshot_file(&self, p: impl AsRef<Path>)
testutils
only.Create a snapshot file from the Env’s current state.
§Panics
If there is any error writing the file.
Trait Implementations§
Source§impl<T0, T1, T2> TryFromVal<Env, (T0, T1, T2)> for Vec<Val>
impl<T0, T1, T2> TryFromVal<Env, (T0, T1, T2)> for Vec<Val>
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0, T1, T2)) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3> TryFromVal<Env, (T0, T1, T2, T3)> for Vec<Val>
impl<T0, T1, T2, T3> TryFromVal<Env, (T0, T1, T2, T3)> for Vec<Val>
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0, T1, T2, T3)) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4> TryFromVal<Env, (T0, T1, T2, T3, T4)> for Vec<Val>
impl<T0, T1, T2, T3, T4> TryFromVal<Env, (T0, T1, T2, T3, T4)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5> TryFromVal<Env, (T0, T1, T2, T3, T4, T5)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5> TryFromVal<Env, (T0, T1, T2, T3, T4, T5)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6, T7> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7, T8), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Vec<Val>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> for Vec<Val>
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11), ) -> Result<Self, Self::Error>
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> for Vec<Val>where
T0: IntoVal<Env, Val>,
T1: IntoVal<Env, Val>,
T2: IntoVal<Env, Val>,
T3: IntoVal<Env, Val>,
T4: IntoVal<Env, Val>,
T5: IntoVal<Env, Val>,
T6: IntoVal<Env, Val>,
T7: IntoVal<Env, Val>,
T8: IntoVal<Env, Val>,
T9: IntoVal<Env, Val>,
T10: IntoVal<Env, Val>,
T11: IntoVal<Env, Val>,
T12: IntoVal<Env, Val>,
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> for Vec<Val>where
T0: IntoVal<Env, Val>,
T1: IntoVal<Env, Val>,
T2: IntoVal<Env, Val>,
T3: IntoVal<Env, Val>,
T4: IntoVal<Env, Val>,
T5: IntoVal<Env, Val>,
T6: IntoVal<Env, Val>,
T7: IntoVal<Env, Val>,
T8: IntoVal<Env, Val>,
T9: IntoVal<Env, Val>,
T10: IntoVal<Env, Val>,
T11: IntoVal<Env, Val>,
T12: IntoVal<Env, Val>,
type Error = ConversionError
fn try_from_val( env: &Env, v: &(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12), ) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, AddressObject> for Address
impl TryFromVal<Env, AddressObject> for Address
type Error = Infallible
fn try_from_val(env: &Env, val: &AddressObject) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, BytesObject> for Bytes
impl TryFromVal<Env, BytesObject> for Bytes
type Error = Infallible
fn try_from_val(env: &Env, val: &BytesObject) -> Result<Self, Self::Error>
Source§impl<const N: usize> TryFromVal<Env, BytesObject> for BytesN<N>
impl<const N: usize> TryFromVal<Env, BytesObject> for BytesN<N>
type Error = ConversionError
fn try_from_val(env: &Env, obj: &BytesObject) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, Context> for Val
impl TryFromVal<Env, Context> for Val
type Error = ConversionError
fn try_from_val(env: &Env, val: &Context) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, ContractContext> for Val
impl TryFromVal<Env, ContractContext> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &ContractContext, ) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, ContractExecutable> for Val
impl TryFromVal<Env, ContractExecutable> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &ContractExecutable, ) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, CreateContractHostFnContext> for Val
impl TryFromVal<Env, CreateContractHostFnContext> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &CreateContractHostFnContext, ) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, CreateContractWithConstructorHostFnContext> for Val
impl TryFromVal<Env, CreateContractWithConstructorHostFnContext> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &CreateContractWithConstructorHostFnContext, ) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, DurationVal> for Duration
impl TryFromVal<Env, DurationVal> for Duration
type Error = Infallible
fn try_from_val(env: &Env, val: &DurationVal) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, InvokerContractAuthEntry> for Val
impl TryFromVal<Env, InvokerContractAuthEntry> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &InvokerContractAuthEntry, ) -> Result<Self, ConversionError>
Source§impl<K, V> TryFromVal<Env, Map<K, V>> for ScVal
impl<K, V> TryFromVal<Env, Map<K, V>> for ScVal
type Error = ConversionError
fn try_from_val(_e: &Env, v: &Map<K, V>) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, ScMap> for ContractContext
impl TryFromVal<Env, ScMap> for ContractContext
Source§impl TryFromVal<Env, ScMap> for CreateContractHostFnContext
impl TryFromVal<Env, ScMap> for CreateContractHostFnContext
Source§impl TryFromVal<Env, ScMap> for SubContractInvocation
impl TryFromVal<Env, ScMap> for SubContractInvocation
Source§impl TryFromVal<Env, ScVal> for ContractContext
impl TryFromVal<Env, ScVal> for ContractContext
Source§impl TryFromVal<Env, ScVal> for ContractExecutable
impl TryFromVal<Env, ScVal> for ContractExecutable
Source§impl TryFromVal<Env, ScVal> for CreateContractHostFnContext
impl TryFromVal<Env, ScVal> for CreateContractHostFnContext
Source§impl TryFromVal<Env, ScVal> for InvokerContractAuthEntry
impl TryFromVal<Env, ScVal> for InvokerContractAuthEntry
Source§impl TryFromVal<Env, ScVal> for SubContractInvocation
impl TryFromVal<Env, ScVal> for SubContractInvocation
Source§impl<T> TryFromVal<Env, ScVal> for Vec<T>
impl<T> TryFromVal<Env, ScVal> for Vec<T>
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, ScVec> for ContractExecutable
impl TryFromVal<Env, ScVec> for ContractExecutable
Source§impl TryFromVal<Env, ScVec> for InvokerContractAuthEntry
impl TryFromVal<Env, ScVec> for InvokerContractAuthEntry
Source§impl TryFromVal<Env, StringObject> for String
impl TryFromVal<Env, StringObject> for String
type Error = Infallible
fn try_from_val(env: &Env, val: &StringObject) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, SubContractInvocation> for Val
impl TryFromVal<Env, SubContractInvocation> for Val
type Error = ConversionError
fn try_from_val( env: &Env, val: &SubContractInvocation, ) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Symbol> for ScVal
impl TryFromVal<Env, Symbol> for ScVal
type Error = ConversionError
fn try_from_val(_e: &Env, v: &Symbol) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, TimepointVal> for Timepoint
impl TryFromVal<Env, TimepointVal> for Timepoint
type Error = Infallible
fn try_from_val(env: &Env, val: &TimepointVal) -> Result<Self, Self::Error>
Source§impl TryFromVal<Env, Val> for Context
impl TryFromVal<Env, Val> for Context
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for ContractContext
impl TryFromVal<Env, Val> for ContractContext
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for ContractExecutable
impl TryFromVal<Env, Val> for ContractExecutable
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for CreateContractHostFnContext
impl TryFromVal<Env, Val> for CreateContractHostFnContext
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for CreateContractWithConstructorHostFnContext
impl TryFromVal<Env, Val> for CreateContractWithConstructorHostFnContext
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for InvokerContractAuthEntry
impl TryFromVal<Env, Val> for InvokerContractAuthEntry
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Source§impl TryFromVal<Env, Val> for SubContractInvocation
impl TryFromVal<Env, Val> for SubContractInvocation
type Error = ConversionError
fn try_from_val(env: &Env, val: &Val) -> Result<Self, ConversionError>
Auto Trait Implementations§
impl Freeze for Env
impl !RefUnwindSafe for Env
impl !Send for Env
impl !Sync for Env
impl Unpin for Env
impl !UnwindSafe for Env
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<E> Compare<AddressObject> for Ewhere
E: Env,
impl<E> Compare<AddressObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &AddressObject, b: &AddressObject, ) -> Result<Ordering, <E as Compare<AddressObject>>::Error>
Source§impl<E> Compare<BytesObject> for Ewhere
E: Env,
impl<E> Compare<BytesObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &BytesObject, b: &BytesObject, ) -> Result<Ordering, <E as Compare<BytesObject>>::Error>
Source§impl<E> Compare<DurationObject> for Ewhere
E: Env,
impl<E> Compare<DurationObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &DurationObject, b: &DurationObject, ) -> Result<Ordering, <E as Compare<DurationObject>>::Error>
Source§impl<E> Compare<DurationSmall> for Ewhere
E: Env,
impl<E> Compare<DurationSmall> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &DurationSmall, b: &DurationSmall, ) -> Result<Ordering, <E as Compare<DurationSmall>>::Error>
Source§impl<E> Compare<I128Object> for Ewhere
E: Env,
impl<E> Compare<I128Object> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &I128Object, b: &I128Object, ) -> Result<Ordering, <E as Compare<I128Object>>::Error>
Source§impl<E> Compare<I256Object> for Ewhere
E: Env,
impl<E> Compare<I256Object> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &I256Object, b: &I256Object, ) -> Result<Ordering, <E as Compare<I256Object>>::Error>
Source§impl<E> Compare<StringObject> for Ewhere
E: Env,
impl<E> Compare<StringObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &StringObject, b: &StringObject, ) -> Result<Ordering, <E as Compare<StringObject>>::Error>
Source§impl<E> Compare<SymbolObject> for Ewhere
E: Env,
impl<E> Compare<SymbolObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &SymbolObject, b: &SymbolObject, ) -> Result<Ordering, <E as Compare<SymbolObject>>::Error>
Source§impl<E> Compare<SymbolSmall> for Ewhere
E: Env,
impl<E> Compare<SymbolSmall> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &SymbolSmall, b: &SymbolSmall, ) -> Result<Ordering, <E as Compare<SymbolSmall>>::Error>
Source§impl<E> Compare<TimepointObject> for Ewhere
E: Env,
impl<E> Compare<TimepointObject> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &TimepointObject, b: &TimepointObject, ) -> Result<Ordering, <E as Compare<TimepointObject>>::Error>
Source§impl<E> Compare<TimepointSmall> for Ewhere
E: Env,
impl<E> Compare<TimepointSmall> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &TimepointSmall, b: &TimepointSmall, ) -> Result<Ordering, <E as Compare<TimepointSmall>>::Error>
Source§impl<E> Compare<U128Object> for Ewhere
E: Env,
impl<E> Compare<U128Object> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &U128Object, b: &U128Object, ) -> Result<Ordering, <E as Compare<U128Object>>::Error>
Source§impl<E> Compare<U256Object> for Ewhere
E: Env,
impl<E> Compare<U256Object> for Ewhere
E: Env,
type Error = <E as EnvBase>::Error
fn compare( &self, a: &U256Object, b: &U256Object, ) -> Result<Ordering, <E as Compare<U256Object>>::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