Struct soroban_sdk::Env
source · pub struct Env { /* private fields */ }
Expand description
Implementations§
source§impl Env
impl Env
sourcepub fn data(&self) -> Storage
👎Deprecated: use env.storage()
pub fn data(&self) -> Storage
Get a Storage for accessing and update contract data that has been stored by the currently executing contract.
sourcepub fn storage(&self) -> Storage
pub fn storage(&self) -> Storage
Get a Storage for accessing and update contract data that has been stored 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 current_contract_address(&self) -> Address
pub fn current_contract_address(&self) -> Address
Get the Address object corresponding to the current executing contract.
sourcepub fn current_contract_id(&self) -> BytesN<32>
pub fn current_contract_id(&self) -> BytesN<32>
Get the 32-byte hash identifier of the current executing contract.
Prefer current_contract_address
for the most cases, unless dealing
with contract-specific functions (like the call stacks).
sourcepub fn call_stack(&self) -> Vec<(BytesN<32>, Symbol)>
pub fn call_stack(&self) -> Vec<(BytesN<32>, Symbol)>
Returns the contract call stack as a Vec
of (contract_id, function_name)
.
Examples
use soroban_sdk::{contractimpl, BytesN, Env, Symbol, symbol};
pub struct Contract;
#[contractimpl]
impl Contract {
pub fn hello(env: Env) {
let stack = env.call_stack();
assert_eq!(stack.len(), 1);
let outer = stack.get(0).unwrap().unwrap();
assert_eq!(outer.0, BytesN::from_array(&env, &[0; 32]));
assert_eq!(outer.1, symbol!("hello"));
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = BytesN::from_array(&env, &[0; 32]);
env.register_contract(&contract_id, Contract);
let client = ContractClient::new(&env, &contract_id);
client.hello();
}
sourcepub fn invoke_contract<T>(
&self,
contract_id: &BytesN<32>,
func: &Symbol,
args: Vec<RawVal>
) -> Twhere
T: TryFromVal<Env, RawVal>,
pub fn invoke_contract<T>(
&self,
contract_id: &BytesN<32>,
func: &Symbol,
args: Vec<RawVal>
) -> Twhere
T: TryFromVal<Env, RawVal>,
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_id: &BytesN<32>,
func: &Symbol,
args: Vec<RawVal>
) -> Result<Result<T, T::Error>, Result<E, E::Error>>where
T: TryFromVal<Env, RawVal>,
E: TryFrom<Status>,
pub fn try_invoke_contract<T, E>(
&self,
contract_id: &BytesN<32>,
func: &Symbol,
args: Vec<RawVal>
) -> Result<Result<T, T::Error>, Result<E, E::Error>>where
T: TryFromVal<Env, RawVal>,
E: TryFrom<Status>,
Invokes a function of a contract that is registered in the Env, returns an error if the invocation fails for any reason.
source§impl Env
impl Env
sourcepub fn register_contract<'a, T: ContractFunctionSet + 'static>(
&self,
contract_id: impl Into<Option<&'a BytesN<32>>>,
contract: T
) -> BytesN<32>
Available on crate feature testutils
only.
pub fn register_contract<'a, T: ContractFunctionSet + 'static>(
&self,
contract_id: impl Into<Option<&'a BytesN<32>>>,
contract: T
) -> BytesN<32>
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 a random ID to be
assigned to the contract.
Registering a contract that is already registered replaces it.
Returns the contract ID of the registered contract.
Examples
use soroban_sdk::{contractimpl, BytesN, Env, Symbol};
pub struct HelloContract;
#[contractimpl]
impl HelloContract {
pub fn hello(env: Env, recipient: soroban_sdk::Symbol) -> soroban_sdk::Symbol {
todo!()
}
}
#[test]
fn test() {
let env = Env::default();
let contract_id = BytesN::from_array(&env, &[0; 32]);
env.register_contract(&contract_id, HelloContract);
}
sourcepub fn register_contract_wasm<'a>(
&self,
contract_id: impl Into<Option<&'a BytesN<32>>>,
contract_wasm: &[u8]
) -> BytesN<32>
Available on crate feature testutils
only.
pub fn register_contract_wasm<'a>(
&self,
contract_id: impl Into<Option<&'a BytesN<32>>>,
contract_wasm: &[u8]
) -> BytesN<32>
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 a random ID to be
assigned to the contract.
Registering a contract that is already registered replaces it.
Returns the contract ID 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(&self, admin: Address) -> BytesN<32>
Available on crate feature testutils
only.
pub fn register_stellar_asset_contract(&self, admin: Address) -> BytesN<32>
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.
Available on crate feature testutils
only.
testutils
only.Returns the recorded top-level require_auth
or require_auth_for_args
calls that have happened during the last contract 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, contract_id, function_name, args)
corresponding to the calls
of require_auth_for_args(address, args)
from the contract function
(contract_id, function_name)
(or require_auth
with all the arguments
of the function invocation).
The order of the returned vector is defined by the order of
require_auth
calls. It is recommended though to do unordered
comparison in case if multiple entries are returned.
‘Top-level call’ here means that this is the first call of
require_auth
for a given address in the call stack; it doesn’t have
to coincide with the actual top-level contract invocation. For example,
if contract A doesn’t use require_auth
and then it calls contract B
that uses require_auth
, then verify_top_authorization
will return
true
when verifying the contract B’s require_auth
call, but it will
return false
if contract A makes a require_auth
call.
It is possible for a single address to be present multiple times in the output, as long as there are multiple disjoint call trees for that address.
Examples
use soroban_sdk::{contractimpl, testutils::Address as _, Address, Env, IntoVal, symbol};
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(None, Contract);
let client = ContractClient::new(&env, &contract_id);
let address = Address::random(&env);
client.transfer(&address, &1000_i128);
assert_eq!(
env.recorded_top_authorizations(),
std::vec![(
address.clone(),
client.contract_id.clone(),
symbol!("transfer"),
(&address, 1000_i128,).into_val(&env)
)]
);
client.transfer2(&address, &1000_i128);
assert_eq!(
env.recorded_top_authorizations(),
std::vec![(
address.clone(),
client.contract_id.clone(),
symbol!("transfer2"),
// `transfer2` requires auth for (amount / 2) == (1000 / 2) == 500.
(500_i128,).into_val(&env)
)]
);
}
sourcepub fn install_contract_wasm(&self, contract_wasm: &[u8]) -> BytesN<32>
Available on crate feature testutils
only.
pub fn install_contract_wasm(&self, contract_wasm: &[u8]) -> BytesN<32>
testutils
only.Install the contract WASM code to the Env for testing.
Returns the hash of the installed code that can be then used for the contract deployment.
Useful for contract factory testing, otherwise use
register_contract_wasm
function that installs and deploys the contract
in a single call.
Examples
use soroban_sdk::{BytesN, Env};
const WASM: &[u8] = include_bytes!("../doctest_fixtures/contract.wasm");
#[test]
fn test() {
let env = Env::default();
env.install_contract_wasm(WASM);
}
sourcepub fn as_contract<T>(&self, id: &BytesN<32>, f: impl FnOnce() -> T) -> T
Available on crate feature testutils
only.
pub fn as_contract<T>(&self, id: &BytesN<32>, 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: LedgerSnapshot) -> Env
Available on crate feature testutils
only.
pub fn from_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_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.
Panics
If there is any error reading the file.
sourcepub fn to_snapshot(&self) -> LedgerSnapshot
Available on crate feature testutils
only.
pub fn to_snapshot(&self) -> LedgerSnapshot
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.Trait Implementations§
source§impl TryFromVal<Env, &[u8]> for Bytes
impl TryFromVal<Env, &[u8]> for Bytes
type Error = ConversionError
fn try_from_val(env: &Env, v: &&[u8]) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, &Address> for RawVal
impl TryFromVal<Env, &Address> for RawVal
type Error = ConversionError
fn try_from_val(_env: &Env, v: &&Address) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, &str> for Bytes
impl TryFromVal<Env, &str> for Bytes
type Error = ConversionError
fn try_from_val(env: &Env, v: &&str) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, ()> for Vec<RawVal>
impl TryFromVal<Env, ()> for Vec<RawVal>
type Error = ConversionError
fn try_from_val(env: &Env, _v: &()) -> 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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
T11: IntoVal<Env, RawVal>,
T12: IntoVal<Env, RawVal>,
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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
T11: IntoVal<Env, RawVal>,
T12: IntoVal<Env, RawVal>,
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<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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
T11: IntoVal<Env, RawVal>,
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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
T11: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
T10: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
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<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
T9: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7, T8)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
T8: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3, T4, T5, T6, T7> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6, T7)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
T7: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3, T4, T5, T6> TryFromVal<Env, (T0, T1, T2, T3, T4, T5, T6)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
T6: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4, T5)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3, T4, T5> TryFromVal<Env, (T0, T1, T2, T3, T4, T5)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
T5: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3, T4)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3, T4> TryFromVal<Env, (T0, T1, T2, T3, T4)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
T4: IntoVal<Env, RawVal>,
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> TryFromVal<Env, (T0, T1, T2, T3)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
impl<T0, T1, T2, T3> TryFromVal<Env, (T0, T1, T2, T3)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
T3: IntoVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0, T1, T2, T3)) -> Result<Self, Self::Error>
source§impl<T0, T1, T2> TryFromVal<Env, (T0, T1, T2)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
impl<T0, T1, T2> TryFromVal<Env, (T0, T1, T2)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
T2: IntoVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0, T1, T2)) -> Result<Self, Self::Error>
source§impl<T0, T1> TryFromVal<Env, (T0, T1)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
impl<T0, T1> TryFromVal<Env, (T0, T1)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
T1: IntoVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0, T1)) -> Result<Self, Self::Error>
source§impl<T0> TryFromVal<Env, (T0,)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
impl<T0> TryFromVal<Env, (T0,)> for Vec<RawVal>where
T0: IntoVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, v: &(T0,)) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Address> for RawVal
impl TryFromVal<Env, Address> for RawVal
type Error = ConversionError
fn try_from_val(_env: &Env, v: &Address) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Bytes> for Bytes
impl TryFromVal<Env, Bytes> for Bytes
type Error = ConversionError
fn try_from_val(_env: &Env, v: &Bytes) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Bytes> for RawVal
impl TryFromVal<Env, Bytes> for RawVal
type Error = ConversionError
fn try_from_val(_env: &Env, v: &Bytes) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, BytesN<N>> for [u8; N]
impl<const N: usize> TryFromVal<Env, BytesN<N>> for [u8; N]
type Error = ConversionError
fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, BytesN<N>> for Bytes
impl<const N: usize> TryFromVal<Env, BytesN<N>> for Bytes
type Error = ConversionError
fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, BytesN<N>> for BytesN<N>
impl<const N: usize> TryFromVal<Env, BytesN<N>> for BytesN<N>
type Error = ConversionError
fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, BytesN<N>> for RawVal
impl<const N: usize> TryFromVal<Env, BytesN<N>> for RawVal
type Error = ConversionError
fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>
source§impl<K, V> TryFromVal<Env, Map<K, V>> for RawValwhere
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<K, V> TryFromVal<Env, Map<K, V>> for RawValwhere
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(_env: &Env, v: &Map<K, V>) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Object> for Address
impl TryFromVal<Env, Object> for Address
type Error = ConversionError
fn try_from_val(env: &Env, val: &Object) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, Object> for Bytes
impl TryFromVal<Env, Object> for Bytes
type Error = ConversionError
fn try_from_val(env: &Env, val: &Object) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, Object> for BytesN<N>
impl<const N: usize> TryFromVal<Env, Object> for BytesN<N>
type Error = ConversionError
fn try_from_val(env: &Env, val: &Object) -> Result<Self, Self::Error>
source§impl<K, V> TryFromVal<Env, Object> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<K, V> TryFromVal<Env, Object> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, obj: &Object) -> Result<Self, Self::Error>
source§impl<T> TryFromVal<Env, Object> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<T> TryFromVal<Env, Object> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, obj: &Object) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, RawVal> for BytesN<N>
impl<const N: usize> TryFromVal<Env, RawVal> for BytesN<N>
type Error = ConversionError
fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>
source§impl<K, V> TryFromVal<Env, RawVal> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<K, V> TryFromVal<Env, RawVal> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
source§impl<T> TryFromVal<Env, RawVal> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<T> TryFromVal<Env, RawVal> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
source§impl<T> TryFromVal<Env, ScObject> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<T> TryFromVal<Env, ScObject> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScObject) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, ScVal> for Address
impl TryFromVal<Env, ScVal> for Address
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl TryFromVal<Env, ScVal> for Bytes
impl TryFromVal<Env, ScVal> for Bytes
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl<const N: usize> TryFromVal<Env, ScVal> for BytesN<N>
impl<const N: usize> TryFromVal<Env, ScVal> for BytesN<N>
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl<K, V> TryFromVal<Env, ScVal> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<K, V> TryFromVal<Env, ScVal> for Map<K, V>where
K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl<T> TryFromVal<Env, ScVal> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<T> TryFromVal<Env, ScVal> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>
source§impl<T> TryFromVal<Env, ScVec> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
impl<T> TryFromVal<Env, ScVec> for Vec<T>where
T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,
type Error = ConversionError
fn try_from_val(env: &Env, val: &ScVec) -> Result<Self, Self::Error>
source§impl<T> TryFromVal<Env, Vec<T>> for Object
impl<T> TryFromVal<Env, Vec<T>> for Object
type Error = ConversionError
fn try_from_val(_env: &Env, v: &Vec<T>) -> Result<Self, Self::Error>
Auto Trait Implementations§
impl !RefUnwindSafe for Env
impl !Send for Env
impl !Sync for Env
impl Unpin for Env
impl !UnwindSafe for Env
Blanket Implementations§
§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
§impl<E> Compare<Object> for Ewhere
E: Env,
impl<E> Compare<Object> for Ewhere
E: Env,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.