Struct soroban_sdk::Env

source ·
pub struct Env { /* private fields */ }
Expand description

The Env type provides access to the environment the contract is executing within.

The Env provides access to information about the currently executing contract, who invoked it, contract data, functions for signing, hashing, etc.

Most types require access to an Env to be constructed or converted.

Implementations§

source§

impl Env

source

pub fn storage(&self) -> Storage

Get a Storage for accessing and updating persistent data owned by the currently executing contract.

source

pub fn events(&self) -> Events

Get Events for publishing events associated with the currently executing contract.

source

pub fn ledger(&self) -> Ledger

Get a Ledger for accessing the current ledger.

source

pub fn deployer(&self) -> Deployer

Get a deployer for deploying contracts.

source

pub fn crypto(&self) -> Crypto

Get a Crypto for accessing the current cryptographic functions.

source

pub fn current_contract_address(&self) -> Address

Get the Address object corresponding to the current executing contract.

source

pub fn call_stack(&self) -> Vec<(Address, Symbol)>

Returns the contract call stack as a Vec of (contract_id, function_name).

Examples
use soroban_sdk::{contractimpl, log, BytesN, Env, 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();
        log!(&env, "{}", outer);
    }
}
#[test]
fn test() {
    let env = Env::default();
    let contract_id = env.register_contract(None, Contract);
    let client = ContractClient::new(&env, &contract_id);
    client.hello();
}
source

pub fn invoke_contract<T>( &self, contract_id: &Address, 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.

source

pub fn try_invoke_contract<T, E>( &self, contract_id: &Address, 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

pub fn logger(&self) -> Logger

Get the Logger for logging debug events.

source

pub fn update_current_contract_wasm(&self, wasm_hash: &BytesN<32>)

Replaces the executable of the current contract with the provided Wasm.

The Wasm blob identified by the wasm_hash has to be already present on-chain (the upload happens via INSTALL_CONTRACT_CODE host function or via install_contract_wasm test function in unit tests).

The function won’t do anything immediately. The contract executable will only be updated after the invocation has successfully finished.

source§

impl Env

source

pub fn register_contract<'a, T: ContractFunctionSet + 'static>( &self, contract_id: impl Into<Option<&'a Address>>, contract: T ) -> Address

Available on crate feature 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: Symbol) -> Symbol {
        todo!()
    }
}

#[test]
fn test() {
    let env = Env::default();
    let contract_id = env.register_contract(None, HelloContract);
}
source

pub fn register_contract_wasm<'a>( &self, contract_id: impl Into<Option<&'a Address>>, contract_wasm: &[u8] ) -> Address

Available on crate feature 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);
}
source

pub fn register_stellar_asset_contract(&self, admin: Address) -> Address

Available on crate feature 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.

source

pub fn set_auths(&self, auths: &[ContractAuth])

Available on crate feature testutils only.

Set authorizations in the environment which will be consumed by contracts when they invoke Address::require_auth or Address::require_auth_for_args functions.

This function can also be called on contract clients.

To mock auth for testing, use mock_all_auths or mock_auths. If mocking of auths is enabled, calling set_auths disables any mocking.

source

pub fn mock_auths(&self, auths: &[MockAuth<'_>])

Available on crate feature 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::{contractimpl, Env, Address, testutils::{Address as _, MockAuth, MockAuthInvoke}, IntoVal};

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_contract(None, HelloContract);

    let client = HelloContractClient::new(&env, &contract_id);
    let addr = Address::random(&env);
    client.mock_auths(&[
        MockAuth {
            address: &addr,
            nonce: 0,
            invoke: &MockAuthInvoke {
                contract: &contract_id,
                fn_name: "hello",
                args: (&addr,).into_val(&env),
                sub_invokes: &[],
            },
        },
    ]).hello(&addr);
}
source

pub fn mock_all_auths(&self)

Available on crate feature 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::{contractimpl, Env, Address, testutils::Address as _};

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_contract(None, HelloContract);

    env.mock_all_auths();

    let client = HelloContractClient::new(&env, &contract_id);
    let addr = Address::random(&env);
    client.hello(&addr);
}
source

pub fn auths(&self) -> Vec<(Address, Address, Symbol, Vec<RawVal>)>

Available on crate feature testutils only.

Returns a list of authorizations that were seen 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 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. Calls to Address::require_auth in disjoint call trees for the same address will present in the list.

Examples
use soroban_sdk::{contractimpl, testutils::Address as _, Address, Symbol, Env, IntoVal};

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);
    env.mock_all_auths();
    let address = Address::random(&env);
    client.transfer(&address, &1000_i128);
    assert_eq!(
        env.auths(),
        std::vec![(
            address.clone(),
            client.contract.clone(),
            Symbol::short("transfer"),
            (&address, 1000_i128,).into_val(&env)
        )]
    );

    client.transfer2(&address, &1000_i128);
    assert_eq!(
        env.auths(),
        std::vec![(
            address.clone(),
            client.contract.clone(),
            Symbol::short("transfer2"),
            // `transfer2` requires auth for (amount / 2) == (1000 / 2) == 500.
            (500_i128,).into_val(&env)
        )]
    );
}
source

pub fn install_contract_wasm(&self, contract_wasm: &[u8]) -> BytesN<32>

Available on crate feature 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);
}
source

pub fn as_contract<T>(&self, id: &Address, f: impl FnOnce() -> T) -> T

Available on crate feature 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.

source

pub fn from_snapshot(s: LedgerSnapshot) -> Env

Available on crate feature testutils only.

Creates a new Env loaded with the LedgerSnapshot.

The ledger info and state in the snapshot are loaded into the Env.

source

pub fn from_snapshot_file(p: impl AsRef<Path>) -> Env

Available on crate feature testutils only.

Creates a new Env loaded with the ledger snapshot loaded from the file.

Panics

If there is any error reading the file.

source

pub fn to_snapshot(&self) -> LedgerSnapshot

Available on crate feature testutils only.

Create a snapshot from the Env’s current state.

source

pub fn to_snapshot_file(&self, p: impl AsRef<Path>)

Available on crate feature testutils only.

Create a snapshot file from the Env’s current state.

Panics

If there is any error writing the file.

source

pub fn budget(&self) -> Budget

Available on crate feature testutils only.

Get the budget that tracks the resources consumed for the environment.

Trait Implementations§

source§

impl Clone for Env

source§

fn clone(&self) -> Env

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Env

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl TryFromVal<Env, &[u8]> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &&[u8]) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &Address> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &&Address) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &I256> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &&I256) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &Symbol> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &&Symbol) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &U256> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &&U256) -> Result<Self, Self::Error>

source§

impl<T> TryFromVal<Env, &Vec<RawVal>> for Vec<T>

§

type Error = Infallible

source§

fn try_from_val(env: &Env, v: &&Vec<RawVal>) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &str> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &&str) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &str> for String

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &&str) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, &str> for Symbol

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &&str) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, [u8; N]> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &[u8; N]) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, [u8; N]> for BytesN<N>

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &[u8; N]) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ()> for Vec<RawVal>

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, _v: &()) -> Result<Self, Self::Error>

source§

impl<T0> TryFromVal<Env, (T0,)> for Vec<RawVal>where T0: IntoVal<Env, RawVal>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &(T0,)) -> Result<Self, Self::Error>

source§

impl<T0, T1> TryFromVal<Env, (T0, T1)> for Vec<RawVal>where T0: IntoVal<Env, RawVal>, T1: IntoVal<Env, RawVal>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, v: &(T0, T1)) -> 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>,

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>,

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>,

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>,

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>,

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>,

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>,

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>,

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>,

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>,

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>,

source§

impl TryFromVal<Env, Address> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &Address) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, AddressObject> for Address

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &AddressObject) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, Bytes> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &Bytes) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, Bytes> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &Bytes) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, BytesN<N>> for [u8; N]

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, BytesN<N>> for Bytes

§

type Error = ConversionError

source§

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>

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, BytesN<N>> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &BytesN<N>) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, BytesObject> for Bytes

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &BytesObject) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, BytesObject> for BytesN<N>

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, obj: &BytesObject) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, I256> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &I256) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, I256Val> for I256

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &I256Val) -> 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>,

§

type Error = Infallible

source§

fn try_from_val(_env: &Env, v: &Map<K, V>) -> Result<Self, Self::Error>

source§

impl<K, V> TryFromVal<Env, Map<K, V>> for ScVal

§

type Error = ConversionError

source§

fn try_from_val(_e: &Env, v: &Map<K, V>) -> Result<Self, Self::Error>

source§

impl<K, V> TryFromVal<Env, MapObject> for Map<K, V>where K: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>, V: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,

§

type Error = Infallible

source§

fn try_from_val(env: &Env, obj: &MapObject) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for Address

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, RawVal> for BytesN<N>

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for I256

§

type Error = ConversionError

source§

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>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for String

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for Symbol

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, RawVal> for U256

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl<T> TryFromVal<Env, RawVal> for Vec<T>where T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &RawVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScAddress> for Address

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScAddress) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScSymbol> for Symbol

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScSymbol) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for Address

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for Bytes

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl<const N: usize> TryFromVal<Env, ScVal> for BytesN<N>

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for I256

§

type Error = ConversionError

source§

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>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for String

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for Symbol

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, ScVal> for U256

§

type Error = ConversionError

source§

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>,

§

type Error = ConversionError

source§

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>,

§

type Error = ConversionError

source§

fn try_from_val(env: &Env, val: &ScVec) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, String> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &String) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, String> for String

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &String) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, StringObject> for String

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &StringObject) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, Symbol> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &Symbol) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, Symbol> for ScVal

§

type Error = ConversionError

source§

fn try_from_val(_e: &Env, v: &Symbol) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, Symbol> for Symbol

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &SymbolVal) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, U256> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &U256) -> Result<Self, Self::Error>

source§

impl TryFromVal<Env, U256Val> for U256

§

type Error = Infallible

source§

fn try_from_val(env: &Env, val: &U256Val) -> Result<Self, Self::Error>

source§

impl<T> TryFromVal<Env, Vec<T>> for RawVal

§

type Error = ConversionError

source§

fn try_from_val(_env: &Env, v: &Vec<T>) -> Result<Self, Self::Error>

source§

impl<T> TryFromVal<Env, Vec<T>> for Vec<RawVal>

§

type Error = Infallible

source§

fn try_from_val(env: &Env, v: &Vec<T>) -> Result<Self, Self::Error>

source§

impl<T> TryFromVal<Env, VecObject> for Vec<T>where T: IntoVal<Env, RawVal> + TryFromVal<Env, RawVal>,

§

type Error = Infallible

source§

fn try_from_val(env: &Env, obj: &VecObject) -> 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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, C> Compare<&T> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare(&self, a: &&T, b: &&T) -> Result<Ordering, <C as Compare<&T>>::Error>

§

impl<T, U, E, C> Compare<(T, U)> for Cwhere C: Compare<T, Error = E, Error = E> + Compare<U>,

§

type Error = E

§

fn compare( &self, a: &(T, U), b: &(T, U) ) -> Result<Ordering, <C as Compare<(T, U)>>::Error>

§

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>,

§

type Error = E

§

fn compare( &self, a: &(T, U, V), b: &(T, U, V) ) -> Result<Ordering, <C as Compare<(T, U, V)>>::Error>

§

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>

§

impl<E> Compare<Bool> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &Bool, b: &Bool ) -> Result<Ordering, <E as Compare<Bool>>::Error>

§

impl<T, C> Compare<Box<T, Global>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Box<T, Global>, b: &Box<T, Global> ) -> Result<Ordering, <C as Compare<Box<T, Global>>>::Error>

§

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>

§

impl<E> Compare<ContractExecutableObject> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &ContractExecutableObject, b: &ContractExecutableObject ) -> Result<Ordering, <E as Compare<ContractExecutableObject>>::Error>

§

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>

§

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>

§

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>

§

impl<E> Compare<I128Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &I128Small, b: &I128Small ) -> Result<Ordering, <E as Compare<I128Small>>::Error>

§

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>

§

impl<E> Compare<I256Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &I256Small, b: &I256Small ) -> Result<Ordering, <E as Compare<I256Small>>::Error>

§

impl<E> Compare<I32Val> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &I32Val, b: &I32Val ) -> Result<Ordering, <E as Compare<I32Val>>::Error>

§

impl<E> Compare<I64Object> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &I64Object, b: &I64Object ) -> Result<Ordering, <E as Compare<I64Object>>::Error>

§

impl<E> Compare<I64Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &I64Small, b: &I64Small ) -> Result<Ordering, <E as Compare<I64Small>>::Error>

§

impl<E> Compare<LedgerKeyNonceObject> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &LedgerKeyNonceObject, b: &LedgerKeyNonceObject ) -> Result<Ordering, <E as Compare<LedgerKeyNonceObject>>::Error>

§

impl<E> Compare<MapObject> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &MapObject, b: &MapObject ) -> Result<Ordering, <E as Compare<MapObject>>::Error>

§

impl<E> Compare<Object> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &Object, b: &Object ) -> Result<Ordering, <E as Compare<Object>>::Error>

§

impl<T, C> Compare<Option<T>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Option<T>, b: &Option<T> ) -> Result<Ordering, <C as Compare<Option<T>>>::Error>

§

impl<E> Compare<RawVal> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &RawVal, b: &RawVal ) -> Result<Ordering, <E as Compare<RawVal>>::Error>

§

impl<T, C> Compare<Rc<T>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Rc<T>, b: &Rc<T> ) -> Result<Ordering, <C as Compare<Rc<T>>>::Error>

§

impl<E> Compare<Status> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &Status, b: &Status ) -> Result<Ordering, <E as Compare<Status>>::Error>

§

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>

§

impl<E> Compare<Symbol> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &Symbol, b: &Symbol ) -> Result<Ordering, <E as Compare<Symbol>>::Error>

§

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>

§

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>

§

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>

§

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>

§

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>

§

impl<E> Compare<U128Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &U128Small, b: &U128Small ) -> Result<Ordering, <E as Compare<U128Small>>::Error>

§

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>

§

impl<E> Compare<U256Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &U256Small, b: &U256Small ) -> Result<Ordering, <E as Compare<U256Small>>::Error>

§

impl<E> Compare<U32Val> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &U32Val, b: &U32Val ) -> Result<Ordering, <E as Compare<U32Val>>::Error>

§

impl<E> Compare<U64Object> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &U64Object, b: &U64Object ) -> Result<Ordering, <E as Compare<U64Object>>::Error>

§

impl<E> Compare<U64Small> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &U64Small, b: &U64Small ) -> Result<Ordering, <E as Compare<U64Small>>::Error>

§

impl<T, C> Compare<Vec<T, Global>> for Cwhere C: Compare<T>,

§

type Error = <C as Compare<T>>::Error

§

fn compare( &self, a: &Vec<T, Global>, b: &Vec<T, Global> ) -> Result<Ordering, <C as Compare<Vec<T, Global>>>::Error>

§

impl<E> Compare<VecObject> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, a: &VecObject, b: &VecObject ) -> Result<Ordering, <E as Compare<VecObject>>::Error>

§

impl<E> Compare<Void> for Ewhere E: Env,

§

type Error = <E as EnvBase>::Error

§

fn compare( &self, _a: &Void, _b: &Void ) -> Result<Ordering, <E as Compare<Void>>::Error>

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert 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>

Convert 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)

Convert &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)

Convert &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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<E, T, U> IntoVal<E, T> for Uwhere E: Env, T: FromVal<E, U>,

source§

fn into_val(&self, e: &E) -> T

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<E, T, U> TryIntoVal<E, T> for Uwhere E: Env, T: TryFromVal<E, U>,

§

type Error = <T as TryFromVal<E, U>>::Error

§

fn try_into_val(&self, env: &E) -> Result<T, <U as TryIntoVal<E, T>>::Error>

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V