Struct soroban_env_host::Host

source ·
pub struct Host(_);

Implementations§

source§

impl Host

source

pub fn ed25519_pub_key_from_bytesobj_input( &self, k: BytesObject ) -> Result<PublicKey, HostError>

source

pub fn sha256_hash_from_bytesobj_input( &self, x: BytesObject ) -> Result<Vec<u8>, HostError>

source

pub fn storage_key_from_rawval( &self, k: RawVal ) -> Result<Rc<LedgerKey>, HostError>

Converts a RawVal to an ScVal and combines it with the currently-executing [ContractID] to produce a [Key], that can be used to access ledger [Storage].

source

pub fn storage_key_from_scval( &self, key: ScVal ) -> Result<Rc<LedgerKey>, HostError>

source

pub fn contract_data_key_from_rawval( &self, k: RawVal ) -> Result<Rc<LedgerKey>, HostError>

source§

impl Host

source§

impl Host

None of these functions are metered, which is why they’re behind the is_debug check

source

pub fn fn_call_diagnostics( &self, called_contract_id: &Hash, func: &Symbol, args: &[RawVal] ) -> Result<(), HostError>

source

pub fn fn_return_diagnostics( &self, contract_id: &Hash, func: &Symbol, res: &RawVal ) -> Result<(), HostError>

source§

impl Host

source

pub fn err<T>(&self, src: T) -> HostErrorwhere DebugError: From<T>,

Records a debug-event from its input in as much detail as possible, then converts its input to a (often coarser-granularity) Status code, and then forms a HostError with it (which also captures a backtrace::Backtrace). This is the method you want to call any time there’s a finer-granularity error type that you want to log the details of and then downgrade fail with.

source

pub fn err_status<T>(&self, status: T) -> HostErrorwhere Status: From<T>,

Helper for the simplest status-only error path.

source

pub fn err_general(&self, msg: &'static str) -> HostError

Helper for the simplest string + general-error path.

source

pub fn err_status_msg<T>(&self, status: T, msg: &'static str) -> HostErrorwhere Status: From<T>,

Helper for the next-simplest status-and-extended-debug-message error path.

source

pub fn err_status_msg_with_args<T>( &self, status: T, msg: &'static str, args: &[RawVal] ) -> HostErrorwhere Status: From<T>,

Helper for the error message with status and an arbitrary number of args.

source

pub fn err_conversion_into_rawval<T>(&self, rv: RawVal) -> HostError

source

pub fn err_conversion_general(&self, msg: &'static str) -> HostError

source

pub fn map_err<T, E>(&self, res: Result<T, E>) -> Result<T, HostError>where DebugError: From<E>,

Given a result carrying some error type that can be converted to a DebugError, calls self.err with it when there’s an error. Returns a result over HostError.

If you have an error type T you want to record as a detailed debug event and a less-detailed Status code embedded in a HostError, add an impl From<T> for DebugError over in the events module and call this where the error is generated.

Note: we do not want to impl From<T> for HostError for such types, as doing so will avoid routing them through the host in order to record their extended diagnostic information into the debug buffer. This means you will wind up writing host.map_err(...)? a bunch in code that you used to be able to get away with just writing ...?, there’s no way around this if we want to record the diagnostic information.

source§

impl Host

source

pub fn with_storage_and_budget(storage: Storage, budget: Budget) -> Self

Constructs a new Host that will use the provided Storage for contract-data access functions such as [Env::get_contract_data].

source

pub fn set_source_account(&self, source_account: AccountId)

source

pub fn remove_source_account(&self)

source

pub fn source_account(&self) -> Option<AccountId>

source

pub fn switch_to_recording_auth(&self)

source

pub fn set_authorization_entries( &self, auth_entries: Vec<ContractAuth> ) -> Result<(), HostError>

source

pub fn set_ledger_info(&self, info: LedgerInfo)

source

pub fn with_ledger_info<F, T>(&self, f: F) -> Result<T, HostError>where F: FnOnce(&LedgerInfo) -> Result<T, HostError>,

source

pub fn with_mut_ledger_info<F>(&self, f: F) -> Result<(), HostError>where F: FnMut(&mut LedgerInfo),

source

pub fn with_budget<T, F>(&self, f: F) -> Twhere F: FnOnce(Budget) -> T,

Helper for mutating the Budget held in this Host, either to allocate it on contract creation or to deplete it on callbacks from the VM or host functions.

source

pub fn budget_cloned(&self) -> Budget

source

pub fn charge_budget(&self, ty: CostType, input: u64) -> Result<(), HostError>

source

pub fn set_diagnostic_level(&self, diagnostic_level: DiagnosticLevel)

source

pub fn is_debug(&self) -> bool

source

pub fn record_debug_event<T>(&self, src: T) -> Result<(), HostError>where DebugEvent: From<T>,

Records a debug event. This in itself is not necessarily an error; it might just be some contextual event we want to put in a debug log for diagnostic purpopses. The return value from this is therefore () when the event is recorded successfully, even if the event itself represented some other error. This function only returns Err(…) when there was a failure to record the event, such as when budget is exceeded.

source

pub fn with_mut_storage<F, U>(&self, f: F) -> Result<U, HostError>where F: FnOnce(&mut Storage) -> Result<U, HostError>,

source

pub fn try_finish(self) -> Result<(Storage, Budget, Events), (Self, HostError)>

Accept a unique (refcount = 1) host reference and destroy the underlying [HostImpl], returning its constituent components to the caller as a tuple wrapped in Ok(...). If the provided host reference is not unique, returns Err(self).

source

pub fn with_test_contract_frame<F>( &self, id: Hash, func: Symbol, f: F ) -> Result<RawVal, HostError>where F: FnOnce() -> Result<RawVal, HostError>,

Pushes a test contract [Frame], runs a closure, and then pops the frame, rolling back if the closure returned an error. Returns the result that the closure returned (or any error caused during the frame push/pop). Used for testing.

source

pub fn call_account_contract_check_auth( &self, contract: BytesObject, args: VecObject ) -> Result<RawVal, HostError>

Invokes the reserved __check_auth function on a provided contract.

This is useful for testing the custom account contracts. Otherwise, the host prohibits calling __check_auth outside of internal implementation of require_auth[_for_args] calls.

source

pub fn inject_val(&self, v: &ScVal) -> Result<RawVal, HostError>

source

pub fn get_events(&self) -> Result<Events, HostError>

source

pub fn invoke_function(&self, hf: HostFunction) -> Result<ScVal, HostError>

source

pub fn register_test_contract( &self, contract_id: BytesObject, contract_fns: Rc<dyn ContractFunctionSet> ) -> Result<(), HostError>

source

pub fn add_ledger_entry( &self, key: &Rc<LedgerKey>, val: &Rc<LedgerEntry> ) -> Result<(), HostError>

source

pub fn get_recorded_top_authorizations( &self ) -> Result<Vec<(ScAddress, Hash, ScSymbol, ScVec)>, HostError>

source

pub fn system_event( &self, topics: VecObject, data: RawVal ) -> Result<RawVal, HostError>

Records a System contract event. topics is expected to be a SCVec length <= 4 that cannot contain Vec, Map, or Bytes with length > 32 On success, returns an SCStatus::Ok.

source

pub fn get_recorded_auth_payloads( &self ) -> Result<Vec<RecordedAuthPayload>, HostError>

Trait Implementations§

source§

impl AsBudget for Host

source§

impl Clone for Host

source§

fn clone(&self) -> Host

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 Compare<AccessType> for Host

source§

impl Compare<AccountEntry> for Host

source§

impl Compare<AccountId> for Host

source§

impl Compare<ClaimableBalanceEntry> for Host

source§

impl Compare<ConfigSettingEntry> for Host

source§

impl Compare<ContractCodeEntry> for Host

source§

impl Compare<DataEntry> for Host

source§

impl Compare<Duration> for Host

§

type Error = HostError

source§

fn compare(&self, a: &Duration, b: &Duration) -> Result<Ordering, Self::Error>

source§

impl Compare<Hash> for Host

§

type Error = HostError

source§

fn compare(&self, a: &Hash, b: &Hash) -> Result<Ordering, Self::Error>

source§

impl Compare<I256> for Host

§

type Error = HostError

source§

fn compare(&self, a: &I256, b: &I256) -> Result<Ordering, Self::Error>

source§

impl Compare<LedgerEntryExt> for Host

source§

impl Compare<LedgerKeyAccount> for Host

source§

impl Compare<LedgerKeyClaimableBalance> for Host

source§

impl Compare<LedgerKeyConfigSetting> for Host

source§

impl Compare<LedgerKeyContractCode> for Host

source§

impl Compare<LedgerKeyData> for Host

source§

impl Compare<LedgerKeyLiquidityPool> for Host

source§

impl Compare<LedgerKeyOffer> for Host

source§

impl Compare<LedgerKeyTrustLine> for Host

source§

impl Compare<LiquidityPoolEntry> for Host

source§

impl<K, V> Compare<MeteredOrdMap<K, V, Host>> for Hostwhere K: MeteredClone, V: MeteredClone, Host: Compare<K, Error = HostError> + Compare<V, Error = HostError>,

§

type Error = HostError

source§

fn compare( &self, a: &MeteredOrdMap<K, V, Host>, b: &MeteredOrdMap<K, V, Host> ) -> Result<Ordering, Self::Error>

source§

impl<Elt: MeteredClone> Compare<MeteredVector<Elt>> for Hostwhere Host: Compare<Elt, Error = HostError>,

§

type Error = HostError

source§

fn compare( &self, a: &MeteredVector<Elt>, b: &MeteredVector<Elt> ) -> Result<Ordering, Self::Error>

source§

impl Compare<OfferEntry> for Host

source§

impl Compare<PublicKey> for Host

source§

impl Compare<ScAddress> for Host

source§

impl Compare<ScContractExecutable> for Host

source§

impl Compare<ScNonceKey> for Host

source§

impl Compare<TimePoint> for Host

source§

impl Compare<TrustLineAsset> for Host

source§

impl Compare<TrustLineEntry> for Host

source§

impl Compare<U256> for Host

§

type Error = HostError

source§

fn compare(&self, a: &U256, b: &U256) -> Result<Ordering, Self::Error>

source§

impl Compare<Uint256> for Host

§

type Error = HostError

source§

fn compare(&self, a: &Uint256, b: &Uint256) -> Result<Ordering, Self::Error>

source§

impl Compare<bool> for Host

§

type Error = HostError

source§

fn compare(&self, a: &bool, b: &bool) -> Result<Ordering, Self::Error>

source§

impl Compare<i128> for Host

§

type Error = HostError

source§

fn compare(&self, a: &i128, b: &i128) -> Result<Ordering, Self::Error>

source§

impl Compare<i32> for Host

§

type Error = HostError

source§

fn compare(&self, a: &i32, b: &i32) -> Result<Ordering, Self::Error>

source§

impl Compare<i64> for Host

§

type Error = HostError

source§

fn compare(&self, a: &i64, b: &i64) -> Result<Ordering, Self::Error>

source§

impl Compare<u128> for Host

§

type Error = HostError

source§

fn compare(&self, a: &u128, b: &u128) -> Result<Ordering, Self::Error>

source§

impl Compare<u32> for Host

§

type Error = HostError

source§

fn compare(&self, a: &u32, b: &u32) -> Result<Ordering, Self::Error>

source§

impl Compare<u64> for Host

§

type Error = HostError

source§

fn compare(&self, a: &u64, b: &u64) -> Result<Ordering, Self::Error>

source§

impl Convert<&Object, ScValObject> for Host

source§

impl<'a> Convert<&ScValObjRef<'a>, Object> for Host

§

type Error = HostError

source§

fn convert(&self, ob: &ScValObjRef<'a>) -> Result<Object, Self::Error>

source§

impl Convert<Object, ScValObject> for Host

source§

impl<'a> Convert<ScValObjRef<'a>, Object> for Host

§

type Error = HostError

source§

fn convert(&self, ob: ScValObjRef<'a>) -> Result<Object, Self::Error>

source§

impl Debug for Host

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Host

source§

fn default() -> Host

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

impl EnvBase for Host

§

type Error = HostError

The type of error returned from the environment when the environment itself fails “unrecoverably”, or at least in a way that the user is not expected to be able to recover from, such as an internal logic error, exceeding the execution budget, or being passed malformed input in a way that the user-facing API does not anticipate or allow for. This type is returned from all environment-interface methods, and will only ever take on two possible concrete types: either Infallible (in the Guest) or HostError (in the Host). Read more
source§

fn escalate_error_to_panic(&self, e: Self::Error) -> !

Reject an error from the environment, turning it into a panic but on terms that the environment controls (eg. transforming or logging it). This should only ever be called by client-side / SDK local-testing code, never in the Host.
source§

fn as_mut_any(&mut self) -> &mut dyn Any

Used for recovering the concrete type of the Host.
source§

fn check_same_env(&self, other: &Self)

Used to check two environments are the same, trapping if not.
source§

fn deep_clone(&self) -> Self

Used to clone an environment deeply, not just a handle to it.
source§

fn bytes_copy_from_slice( &self, b: BytesObject, b_pos: U32Val, slice: &[u8] ) -> Result<BytesObject, HostError>

Clone an existing Bytes object in the host, replacing the portion of its memory with bytes supplied by slice, returning the new object. The replaced portion of the original object’s memory begins at b_pos and extends for the same length as the new slice.
source§

fn bytes_copy_to_slice( &self, b: BytesObject, b_pos: U32Val, slice: &mut [u8] ) -> Result<(), HostError>

Copy a slice of bytes from a Bytes object in the host into a slice in the caller’s memory.
source§

fn string_copy_to_slice( &self, b: StringObject, b_pos: U32Val, slice: &mut [u8] ) -> Result<(), HostError>

Copy a slice of bytes from a String object in the host into a slice in the caller’s memory.
source§

fn symbol_copy_to_slice( &self, s: SymbolObject, b_pos: U32Val, slice: &mut [u8] ) -> Result<(), HostError>

Copy a slice of bytes from a Symbol object in the host into the caller’s memory.
source§

fn bytes_new_from_slice(&self, mem: &[u8]) -> Result<BytesObject, HostError>

Form a new Bytes host object from a slice of client memory.
source§

fn string_new_from_slice(&self, s: &str) -> Result<StringObject, HostError>

Form a new String host object from a slice of client memory.
source§

fn symbol_new_from_slice(&self, s: &str) -> Result<SymbolObject, HostError>

Form a new Symbol host object from a slice of client memory.
source§

fn map_new_from_slices( &self, keys: &[&str], vals: &[RawVal] ) -> Result<MapObject, HostError>

Form a new Map host object from a slice of symbol-names and a slice of values. Keys must be in sorted order.
source§

fn map_unpack_to_slice( &self, map: MapObject, keys: &[&str], vals: &mut [RawVal] ) -> Result<Void, HostError>

Unpack a Map host object with a specified set of keys to a slice of RawVals. Keys must be in sorted order and must match the key set of the unpacked object exactly.
source§

fn vec_new_from_slice(&self, vals: &[RawVal]) -> Result<VecObject, Self::Error>

Form a new Vec host object from a slice of values.
source§

fn vec_unpack_to_slice( &self, vec: VecObject, vals: &mut [RawVal] ) -> Result<Void, Self::Error>

Form a new Vec host object from a slice of values. The values slice must be the same length as the host object.
source§

fn symbol_index_in_strs( &self, sym: Symbol, slices: &[&str] ) -> Result<U32Val, Self::Error>

Return the index of a Symbol in an array of &strs, or error if not found.
source§

fn log_static_fmt_val( &self, fmt: &'static str, v: RawVal ) -> Result<(), HostError>

Log a formatted debugging message to the debug log (if present), passing a simplified format string (supporting only positional {} markers) and a single RawVal argument that will be inserted at the marker in the format string.
source§

fn log_static_fmt_static_str( &self, fmt: &'static str, s: &'static str ) -> Result<(), HostError>

Log a formatted debugging message to the debug log (if present), passing a simplified format string (supporting only positional {} markers) and a single string-slice argument that will be inserted at the marker in the format string.
source§

fn log_static_fmt_val_static_str( &self, fmt: &'static str, v: RawVal, s: &'static str ) -> Result<(), HostError>

Log a formatted debugging message to the debug log (if present), passing a simplified format string (supporting only positional {} markers) and both a RawVal and a string-slice argument, that will each be inserted at markers in the format string.
source§

fn log_static_fmt_general( &self, fmt: &'static str, vals: &[RawVal], strs: &[&'static str] ) -> Result<(), HostError>

Log a formatted debugging message to the debug log (if present), passing a simplified format string (supporting only positional {} markers) and both a slice of RawVals and a slice of string-slice argument, that will be sequentially inserted at markers in the format string.
source§

impl VmCallerEnv for Host

§

type VmUserState = Host

source§

fn log_value( &self, _vmcaller: &mut VmCaller<'_, Host>, v: RawVal ) -> Result<Void, HostError>

This one variant of logging does not take a format string and is live in both Env=Guest and Env=Host configurations.
source§

fn log_fmt_values( &self, _vmcaller: &mut VmCaller<'_, Host>, fmt: StringObject, args: VecObject ) -> Result<Void, HostError>

Record a debug event. Fmt must be a Bytes. Args must be a Vec. Void is returned.
source§

fn get_invoking_contract( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<Object, HostError>

Get the contractID Bytes of the contract which invoked the running contract. Traps if the running contract was not invoked by a contract.
source§

fn obj_cmp( &self, _vmcaller: &mut VmCaller<'_, Host>, a: RawVal, b: RawVal ) -> Result<i64, HostError>

Compare two objects, or at least one object to a non-object, structurally. Returns -1 if a<b, 1 if a>b, or 0 if a==b.
source§

fn contract_event( &self, _vmcaller: &mut VmCaller<'_, Host>, topics: VecObject, data: RawVal ) -> Result<Void, HostError>

Records a contract event. topics is expected to be a SCVec with length <= 4 that cannot contain Vec, Map, or Bytes with length > 32 On success, returns an SCStatus::Ok.
source§

fn get_current_contract_address( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<AddressObject, HostError>

Get the Address object for the current contract.
source§

fn obj_from_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, u: u64 ) -> Result<U64Object, HostError>

Convert a u64 to an object containing a u64.
source§

fn obj_to_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: U64Object ) -> Result<u64, HostError>

Convert an object containing a i64 to a u64.
source§

fn obj_from_i64( &self, _vmcaller: &mut VmCaller<'_, Host>, i: i64 ) -> Result<I64Object, HostError>

Convert an i64 to an object containing an i64.
source§

fn obj_to_i64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: I64Object ) -> Result<i64, HostError>

Convert an object containing an i64 to an i64.
source§

fn obj_from_u128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lo: u64, hi: u64 ) -> Result<U128Object, Self::Error>

Convert the low and high 64-bit words of a u128 to an object containing a u128.
source§

fn obj_to_u128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>

Extract the low 64 bits from an object containing a u128.
source§

fn obj_to_u128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>

Extract the high 64 bits from an object containing a u128.
source§

fn obj_from_i128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lo: u64, hi: u64 ) -> Result<I128Object, Self::Error>

Convert the lo and hi 64-bit words of an i128 to an object containing an i128.
source§

fn obj_to_i128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<u64, Self::Error>

Extract the low 64 bits from an object containing an i128.
source§

fn obj_to_i128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<u64, Self::Error>

Extract the high 64 bits from an object containing an i128.
source§

fn map_new( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<MapObject, HostError>

Create an empty new map.
source§

fn map_put( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal, v: RawVal ) -> Result<MapObject, HostError>

Insert a key/value mapping into an existing map, and return the map object handle. If the map already has a mapping for the given key, the previous value is overwritten.
source§

fn map_get( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal ) -> Result<RawVal, HostError>

Get the value for a key from a map. Traps if key is not found.
source§

fn map_del( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal ) -> Result<MapObject, HostError>

Remove a key/value mapping from a map if it exists, traps if doesn’t.
source§

fn map_len( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject ) -> Result<U32Val, HostError>

Get the size of a map.
source§

fn map_has( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal ) -> Result<Bool, HostError>

Test for the presence of a key in a map. Returns Bool.
source§

fn map_prev_key( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal ) -> Result<RawVal, HostError>

Given a key, find the first key less than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).
source§

fn map_next_key( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: RawVal ) -> Result<RawVal, HostError>

Given a key, find the first key greater than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).
source§

fn map_min_key( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject ) -> Result<RawVal, HostError>

Find the minimum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
source§

fn map_max_key( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject ) -> Result<RawVal, HostError>

Find the maximum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
source§

fn map_keys( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject ) -> Result<VecObject, HostError>

Return a new vector containing all the keys in a map. The new vector is ordered in the original map’s key-sorted order.
source§

fn map_values( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject ) -> Result<VecObject, HostError>

Return a new vector containing all the values in a map. The new vector is ordered in the original map’s key-sorted order.
source§

fn map_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<MapObject, HostError>

Return a new map initialized from a set of input slices given by linear-memory addresses and lengths.
source§

fn map_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, map: MapObject, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<Void, HostError>

Copy the RawVal values of a map, as described by set of input keys, into an array at a given linear-memory address.
source§

fn vec_new( &self, _vmcaller: &mut VmCaller<'_, Host>, c: RawVal ) -> Result<VecObject, HostError>

Creates a new vector with an optional capacity hint c. If c is ScStatic::Void, no hint is assumed and the new vector is empty. Otherwise, c is parsed as an u32 that represents the initial capacity of the new vector.
source§

fn vec_put( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, HostError>

Update the value at index i in the vector. Return the new vector. Trap if the index is out of bounds.
source§

fn vec_get( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val ) -> Result<RawVal, HostError>

Returns the element at index i of the vector. Traps if the index is out of bound.
source§

fn vec_del( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val ) -> Result<VecObject, HostError>

Delete an element in a vector at index i, shifting all elements after it to the left. Return the new vector. Traps if the index is out of bound.
source§

fn vec_len( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject ) -> Result<U32Val, HostError>

Returns length of the vector.
source§

fn vec_push_front( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: RawVal ) -> Result<VecObject, HostError>

Push a value to the front of a vector.
source§

fn vec_pop_front( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject ) -> Result<VecObject, HostError>

Removes the first element from the vector and returns the new vector. Traps if original vector is empty.
source§

fn vec_push_back( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: RawVal ) -> Result<VecObject, HostError>

Appends an element to the back of the vector.
source§

fn vec_pop_back( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject ) -> Result<VecObject, HostError>

Removes the last element from the vector and returns the new vector. Traps if original vector is empty.
source§

fn vec_front( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject ) -> Result<RawVal, HostError>

Return the first element in the vector. Traps if the vector is empty
source§

fn vec_back( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject ) -> Result<RawVal, HostError>

Return the last element in the vector. Traps if the vector is empty
source§

fn vec_insert( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, HostError>

Inserts an element at index i within the vector, shifting all elements after it to the right. Traps if the index is out of bound
source§

fn vec_append( &self, _vmcaller: &mut VmCaller<'_, Host>, v1: VecObject, v2: VecObject ) -> Result<VecObject, HostError>

Clone the vector v1, then moves all the elements of vector v2 into it. Return the new vector. Traps if number of elements in the vector overflows a u32.
source§

fn vec_slice( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, start: U32Val, end: U32Val ) -> Result<VecObject, HostError>

Copy the elements from start index until end index, exclusive, in the vector and create a new vector from it. Return the new vector. Traps if the index is out of bound.
source§

fn vec_first_index_of( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>

Get the index of the first occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.
source§

fn vec_last_index_of( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>

Get the index of the last occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.
Binary search a sorted vector for a given element. If it exists, the high-32 bits of the return value is 0x0001 and the low-32 bits contain the u32 index of the element. If it does not exist, the high-32 bits of the return value is 0x0000 and the low-32 bits contain the u32 index at which the element would need to be inserted into the vector to maintain sorted order.
source§

fn vec_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, vals_pos: U32Val, len: U32Val ) -> Result<VecObject, HostError>

Return a new vec initialized from an input slice of RawVals given by a linear-memory address and length.
source§

fn vec_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, vec: VecObject, vals_pos: U32Val, len: U32Val ) -> Result<Void, HostError>

Copy the RawVals of a vec into an array at a given linear-memory address.
source§

fn put_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: RawVal, v: RawVal ) -> Result<RawVal, HostError>

source§

fn has_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: RawVal ) -> Result<Bool, HostError>

source§

fn get_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: RawVal ) -> Result<RawVal, HostError>

source§

fn del_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: RawVal ) -> Result<RawVal, HostError>

source§

fn create_contract_from_contract( &self, _vmcaller: &mut VmCaller<'_, Host>, wasm_hash: BytesObject, salt: BytesObject ) -> Result<BytesObject, HostError>

Deploys a contract from the current contract. wasm_hash must be a hash of the contract code that has already been installed on this network. salt is used to create a unique contract id.
source§

fn call( &self, _vmcaller: &mut VmCaller<'_, Host>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, HostError>

Calls a function in another contract with arguments contained in vector args. If the call is successful, forwards the result of the called function. Traps otherwise.
source§

fn try_call( &self, vmcaller: &mut VmCaller<'_, Host>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, HostError>

Calls a function in another contract with arguments contained in vector args. Returns: - if successful, result of the called function. - otherwise, an SCStatus containing the error status code.
source§

fn serialize_to_bytes( &self, _vmcaller: &mut VmCaller<'_, Host>, v: RawVal ) -> Result<BytesObject, HostError>

Serializes an (SC)Val into XDR opaque Bytes object.
source§

fn deserialize_from_bytes( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject ) -> Result<RawVal, HostError>

Deserialize a Bytes object to get back the (SC)Val.
source§

fn string_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, s: StringObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, HostError>

Copies a slice of bytes from a String object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.
source§

fn symbol_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, HostError>

Copies a slice of bytes from a Symbol object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.
source§

fn bytes_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, HostError>

Copies a slice of bytes from a Bytes object specified at offset b_pos with length len into the linear memory at position lm_pos. Traps if either the Bytes object or the linear memory doesn’t have enough bytes.
source§

fn bytes_copy_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, HostError>

Copies a segment of the linear memory specified at position lm_pos with length len, into a Bytes object at offset b_pos. The Bytes object may grow in size to accommodate the new bytes. Traps if the linear memory doesn’t have enough bytes.
source§

fn bytes_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, HostError>

Constructs a new Bytes object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn string_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, lm_pos: U32Val, len: U32Val ) -> Result<StringObject, HostError>

Constructs a new String object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn symbol_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, lm_pos: U32Val, len: U32Val ) -> Result<SymbolObject, HostError>

Constructs a new Symbol object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn symbol_index_in_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, sym: Symbol, lm_pos: U32Val, len: U32Val ) -> Result<U32Val, HostError>

Return the index of a Symbol in an array of linear-memory byte-slices, or trap if not found.
source§

fn bytes_new( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<BytesObject, HostError>

Create an empty new Bytes object.
source§

fn bytes_put( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, HostError>

Update the value at index i in the Bytes object. Return the new Bytes. Trap if the index is out of bounds.
source§

fn bytes_get( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, i: U32Val ) -> Result<U32Val, HostError>

Returns the element at index i of the Bytes object. Traps if the index is out of bound.
source§

fn bytes_del( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, i: U32Val ) -> Result<BytesObject, HostError>

Delete an element in a Bytes object at index i, shifting all elements after it to the left. Return the new Bytes. Traps if the index is out of bound.
source§

fn bytes_len( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject ) -> Result<U32Val, HostError>

Returns length of the Bytes object.
source§

fn string_len( &self, _vmcaller: &mut VmCaller<'_, Host>, b: StringObject ) -> Result<U32Val, HostError>

Returns length of the String object.
source§

fn symbol_len( &self, _vmcaller: &mut VmCaller<'_, Host>, b: SymbolObject ) -> Result<U32Val, HostError>

Returns length of the Symbol object.
source§

fn bytes_push( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, u: U32Val ) -> Result<BytesObject, HostError>

Appends an element to the back of the Bytes object.
source§

fn bytes_pop( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject ) -> Result<BytesObject, HostError>

Removes the last element from the Bytes object and returns the new Bytes. Traps if original Bytes is empty.
source§

fn bytes_front( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject ) -> Result<U32Val, HostError>

Return the first element in the Bytes object. Traps if the Bytes is empty
source§

fn bytes_back( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject ) -> Result<U32Val, HostError>

Return the last element in the Bytes object. Traps if the Bytes is empty
source§

fn bytes_insert( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, HostError>

Inserts an element at index i within the Bytes object, shifting all elements after it to the right. Traps if the index is out of bound
source§

fn bytes_append( &self, _vmcaller: &mut VmCaller<'_, Host>, b1: BytesObject, b2: BytesObject ) -> Result<BytesObject, HostError>

Clone the Bytes object b1, then moves all the elements of Bytes object b2 into it. Return the new Bytes. Traps if its length overflows a u32.
source§

fn bytes_slice( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, start: U32Val, end: U32Val ) -> Result<BytesObject, HostError>

Copies the elements from start index until end index, exclusive, in the Bytes object and creates a new Bytes from it. Returns the new Bytes. Traps if the index is out of bound.
source§

fn compute_hash_sha256( &self, _vmcaller: &mut VmCaller<'_, Host>, x: BytesObject ) -> Result<BytesObject, HostError>

source§

fn verify_sig_ed25519( &self, _vmcaller: &mut VmCaller<'_, Host>, x: BytesObject, k: BytesObject, s: BytesObject ) -> Result<Void, HostError>

source§

fn get_ledger_version( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<U32Val, Self::Error>

Return the protocol version of the current ledger as a u32.
source§

fn get_ledger_sequence( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<U32Val, Self::Error>

Return the sequence number of the current ledger as a u32.
source§

fn get_ledger_timestamp( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<U64Val, Self::Error>

Return the timestamp number of the current ledger as a u64.
source§

fn get_ledger_network_id( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<BytesObject, Self::Error>

Return the network id (sha256 hash of network passphrase) of the current ledger as Bytes. The value is always 32 bytes in length.
source§

fn get_current_call_stack( &self, _vmcaller: &mut VmCaller<'_, Host> ) -> Result<VecObject, HostError>

Returns the full call stack from the first contract call to the current one as a vector of vectors, where the inside vector contains the contract id as Hash, and a function as a Symbol.
source§

fn fail_with_status( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, status: Status ) -> Result<Void, Self::Error>

Causes the currently executing contract to fail immediately with a provided status code, which must be of error-type ScStatusType::ContractError. Does not actually return.
source§

fn dummy0( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<RawVal, Self::Error>

A dummy function taking 0 arguments and performs no-op. This function is for test purpose only, for measuring the roundtrip cost of invoking a host function, i.e. host->Vm->host.
source§

fn require_auth_for_args( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject, args: VecObject ) -> Result<RawVal, Self::Error>

Checks if the address has authorized the invocation of the current contract function with the provided arguments. Traps if the invocation hasn’t been authorized.
source§

fn require_auth( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Checks if the address has authorized the invocation of the current contract function with all the arguments of the invocation. Traps if the invocation hasn’t been authorized.
source§

fn get_current_contract_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>

Gets the 32-byte identifer of the current contract. Traps if the running contract was not invoked by a contract.
source§

fn account_public_key_to_address( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, pk_bytes: BytesObject ) -> Result<AddressObject, Self::Error>

Converts a provided 32-byte Stellar account public key to the corresponding address. This is only useful in the context of cross-chain interoperability. Prefer directly using the Address objects whenever possible.
source§

fn contract_id_to_address( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract_id_bytes: BytesObject ) -> Result<AddressObject, Self::Error>

Converts a provided 32-byte contract identifier to a corresponding Address object.
source§

fn address_to_account_public_key( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Returns the 32-byte public key of the Stellar account corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).
source§

fn address_to_contract_id( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Returns the 32-byte contract identifier corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).

Auto Trait Implementations§

§

impl !RefUnwindSafe for Host

§

impl !Send for Host

§

impl !Sync for Host

§

impl Unpin for Host

§

impl !UnwindSafe for Host

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

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

§

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

source§

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

source§

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

§

type Error = E

source§

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

source§

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

source§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

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

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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

source§

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

§

type Error = <E as EnvBase>::Error

source§

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> Env for Twhere T: VmCallerEnv,

source§

fn log_value(&self, v: RawVal) -> Result<Void, <T as EnvBase>::Error>

This one variant of logging does not take a format string and is live in both Env=Guest and Env=Host configurations.
source§

fn get_invoking_contract(&self) -> Result<Object, <T as EnvBase>::Error>

Get the contractID Bytes of the contract which invoked the running contract. Traps if the running contract was not invoked by a contract.
source§

fn obj_cmp(&self, a: RawVal, b: RawVal) -> Result<i64, <T as EnvBase>::Error>

Compare two objects, or at least one object to a non-object, structurally. Returns -1 if a<b, 1 if a>b, or 0 if a==b.
source§

fn contract_event( &self, topics: VecObject, data: RawVal ) -> Result<Void, <T as EnvBase>::Error>

Records a contract event. topics is expected to be a SCVec with length <= 4 that cannot contain Vec, Map, or Bytes with length > 32 On success, returns an SCStatus::Ok.
source§

fn get_current_contract_id(&self) -> Result<BytesObject, <T as EnvBase>::Error>

Gets the 32-byte identifer of the current contract. Traps if the running contract was not invoked by a contract.
source§

fn get_ledger_version(&self) -> Result<U32Val, <T as EnvBase>::Error>

Return the protocol version of the current ledger as a u32.
source§

fn get_ledger_sequence(&self) -> Result<U32Val, <T as EnvBase>::Error>

Return the sequence number of the current ledger as a u32.
source§

fn get_ledger_timestamp(&self) -> Result<U64Val, <T as EnvBase>::Error>

Return the timestamp number of the current ledger as a u64.
source§

fn get_current_call_stack(&self) -> Result<VecObject, <T as EnvBase>::Error>

Returns the full call stack from the first contract call to the current one as a vector of vectors, where the inside vector contains the contract id as Hash, and a function as a Symbol.
source§

fn fail_with_status( &self, status: Status ) -> Result<Void, <T as EnvBase>::Error>

Causes the currently executing contract to fail immediately with a provided status code, which must be of error-type ScStatusType::ContractError. Does not actually return.
source§

fn log_fmt_values( &self, fmt: StringObject, args: VecObject ) -> Result<Void, <T as EnvBase>::Error>

Record a debug event. Fmt must be a Bytes. Args must be a Vec. Void is returned.
source§

fn get_ledger_network_id(&self) -> Result<BytesObject, <T as EnvBase>::Error>

Return the network id (sha256 hash of network passphrase) of the current ledger as Bytes. The value is always 32 bytes in length.
source§

fn get_current_contract_address( &self ) -> Result<AddressObject, <T as EnvBase>::Error>

Get the Address object for the current contract.
source§

fn obj_from_u64(&self, v: u64) -> Result<U64Object, <T as EnvBase>::Error>

Convert a u64 to an object containing a u64.
source§

fn obj_to_u64(&self, obj: U64Object) -> Result<u64, <T as EnvBase>::Error>

Convert an object containing a i64 to a u64.
source§

fn obj_from_i64(&self, v: i64) -> Result<I64Object, <T as EnvBase>::Error>

Convert an i64 to an object containing an i64.
source§

fn obj_to_i64(&self, obj: I64Object) -> Result<i64, <T as EnvBase>::Error>

Convert an object containing an i64 to an i64.
source§

fn obj_from_u128_pieces( &self, lo: u64, hi: u64 ) -> Result<U128Object, <T as EnvBase>::Error>

Convert the low and high 64-bit words of a u128 to an object containing a u128.
source§

fn obj_to_u128_lo64( &self, obj: U128Object ) -> Result<u64, <T as EnvBase>::Error>

Extract the low 64 bits from an object containing a u128.
source§

fn obj_to_u128_hi64( &self, obj: U128Object ) -> Result<u64, <T as EnvBase>::Error>

Extract the high 64 bits from an object containing a u128.
source§

fn obj_from_i128_pieces( &self, lo: u64, hi: u64 ) -> Result<I128Object, <T as EnvBase>::Error>

Convert the lo and hi 64-bit words of an i128 to an object containing an i128.
source§

fn obj_to_i128_lo64( &self, obj: I128Object ) -> Result<u64, <T as EnvBase>::Error>

Extract the low 64 bits from an object containing an i128.
source§

fn obj_to_i128_hi64( &self, obj: I128Object ) -> Result<u64, <T as EnvBase>::Error>

Extract the high 64 bits from an object containing an i128.
source§

fn map_new(&self) -> Result<MapObject, <T as EnvBase>::Error>

Create an empty new map.
source§

fn map_put( &self, m: MapObject, k: RawVal, v: RawVal ) -> Result<MapObject, <T as EnvBase>::Error>

Insert a key/value mapping into an existing map, and return the map object handle. If the map already has a mapping for the given key, the previous value is overwritten.
source§

fn map_get( &self, m: MapObject, k: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

Get the value for a key from a map. Traps if key is not found.
source§

fn map_del( &self, m: MapObject, k: RawVal ) -> Result<MapObject, <T as EnvBase>::Error>

Remove a key/value mapping from a map if it exists, traps if doesn’t.
source§

fn map_len(&self, m: MapObject) -> Result<U32Val, <T as EnvBase>::Error>

Get the size of a map.
source§

fn map_has( &self, m: MapObject, k: RawVal ) -> Result<Bool, <T as EnvBase>::Error>

Test for the presence of a key in a map. Returns Bool.
source§

fn map_prev_key( &self, m: MapObject, k: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

Given a key, find the first key less than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).
source§

fn map_next_key( &self, m: MapObject, k: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

Given a key, find the first key greater than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).
source§

fn map_min_key(&self, m: MapObject) -> Result<RawVal, <T as EnvBase>::Error>

Find the minimum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
source§

fn map_max_key(&self, m: MapObject) -> Result<RawVal, <T as EnvBase>::Error>

Find the maximum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
source§

fn map_keys(&self, m: MapObject) -> Result<VecObject, <T as EnvBase>::Error>

Return a new vector containing all the keys in a map. The new vector is ordered in the original map’s key-sorted order.
source§

fn map_values(&self, m: MapObject) -> Result<VecObject, <T as EnvBase>::Error>

Return a new vector containing all the values in a map. The new vector is ordered in the original map’s key-sorted order.
source§

fn map_new_from_linear_memory( &self, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<MapObject, <T as EnvBase>::Error>

Return a new map initialized from a set of input slices given by linear-memory addresses and lengths.
source§

fn map_unpack_to_linear_memory( &self, map: MapObject, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<Void, <T as EnvBase>::Error>

Copy the RawVal values of a map, as described by set of input keys, into an array at a given linear-memory address.
source§

fn vec_new(&self, c: RawVal) -> Result<VecObject, <T as EnvBase>::Error>

Creates a new vector with an optional capacity hint c. If c is ScStatic::Void, no hint is assumed and the new vector is empty. Otherwise, c is parsed as an u32 that represents the initial capacity of the new vector.
source§

fn vec_put( &self, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, <T as EnvBase>::Error>

Update the value at index i in the vector. Return the new vector. Trap if the index is out of bounds.
source§

fn vec_get( &self, v: VecObject, i: U32Val ) -> Result<RawVal, <T as EnvBase>::Error>

Returns the element at index i of the vector. Traps if the index is out of bound.
source§

fn vec_del( &self, v: VecObject, i: U32Val ) -> Result<VecObject, <T as EnvBase>::Error>

Delete an element in a vector at index i, shifting all elements after it to the left. Return the new vector. Traps if the index is out of bound.
source§

fn vec_len(&self, v: VecObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the vector.
source§

fn vec_push_front( &self, v: VecObject, x: RawVal ) -> Result<VecObject, <T as EnvBase>::Error>

Push a value to the front of a vector.
source§

fn vec_pop_front( &self, v: VecObject ) -> Result<VecObject, <T as EnvBase>::Error>

Removes the first element from the vector and returns the new vector. Traps if original vector is empty.
source§

fn vec_push_back( &self, v: VecObject, x: RawVal ) -> Result<VecObject, <T as EnvBase>::Error>

Appends an element to the back of the vector.
source§

fn vec_pop_back(&self, v: VecObject) -> Result<VecObject, <T as EnvBase>::Error>

Removes the last element from the vector and returns the new vector. Traps if original vector is empty.
source§

fn vec_front(&self, v: VecObject) -> Result<RawVal, <T as EnvBase>::Error>

Return the first element in the vector. Traps if the vector is empty
source§

fn vec_back(&self, v: VecObject) -> Result<RawVal, <T as EnvBase>::Error>

Return the last element in the vector. Traps if the vector is empty
source§

fn vec_insert( &self, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, <T as EnvBase>::Error>

Inserts an element at index i within the vector, shifting all elements after it to the right. Traps if the index is out of bound
source§

fn vec_append( &self, v1: VecObject, v2: VecObject ) -> Result<VecObject, <T as EnvBase>::Error>

Clone the vector v1, then moves all the elements of vector v2 into it. Return the new vector. Traps if number of elements in the vector overflows a u32.
source§

fn vec_slice( &self, v: VecObject, start: U32Val, end: U32Val ) -> Result<VecObject, <T as EnvBase>::Error>

Copy the elements from start index until end index, exclusive, in the vector and create a new vector from it. Return the new vector. Traps if the index is out of bound.
source§

fn vec_first_index_of( &self, v: VecObject, x: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

Get the index of the first occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.
source§

fn vec_last_index_of( &self, v: VecObject, x: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

Get the index of the last occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.
source§

fn vec_binary_search( &self, v: VecObject, x: RawVal ) -> Result<u64, <T as EnvBase>::Error>

Binary search a sorted vector for a given element. If it exists, the high-32 bits of the return value is 0x0001 and the low-32 bits contain the u32 index of the element. If it does not exist, the high-32 bits of the return value is 0x0000 and the low-32 bits contain the u32 index at which the element would need to be inserted into the vector to maintain sorted order.
source§

fn vec_new_from_linear_memory( &self, vals_pos: U32Val, len: U32Val ) -> Result<VecObject, <T as EnvBase>::Error>

Return a new vec initialized from an input slice of RawVals given by a linear-memory address and length.
source§

fn vec_unpack_to_linear_memory( &self, vec: VecObject, vals_pos: U32Val, len: U32Val ) -> Result<Void, <T as EnvBase>::Error>

Copy the RawVals of a vec into an array at a given linear-memory address.
source§

fn put_contract_data( &self, k: RawVal, v: RawVal ) -> Result<RawVal, <T as EnvBase>::Error>

source§

fn has_contract_data(&self, k: RawVal) -> Result<Bool, <T as EnvBase>::Error>

source§

fn get_contract_data(&self, k: RawVal) -> Result<RawVal, <T as EnvBase>::Error>

source§

fn del_contract_data(&self, k: RawVal) -> Result<RawVal, <T as EnvBase>::Error>

source§

fn create_contract_from_contract( &self, wasm_hash: BytesObject, salt: BytesObject ) -> Result<BytesObject, <T as EnvBase>::Error>

Deploys a contract from the current contract. wasm_hash must be a hash of the contract code that has already been installed on this network. salt is used to create a unique contract id.
source§

fn call( &self, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, <T as EnvBase>::Error>

Calls a function in another contract with arguments contained in vector args. If the call is successful, forwards the result of the called function. Traps otherwise.
source§

fn try_call( &self, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, <T as EnvBase>::Error>

Calls a function in another contract with arguments contained in vector args. Returns: - if successful, result of the called function. - otherwise, an SCStatus containing the error status code.
source§

fn serialize_to_bytes( &self, v: RawVal ) -> Result<BytesObject, <T as EnvBase>::Error>

Serializes an (SC)Val into XDR opaque Bytes object.
source§

fn deserialize_from_bytes( &self, b: BytesObject ) -> Result<RawVal, <T as EnvBase>::Error>

Deserialize a Bytes object to get back the (SC)Val.
source§

fn bytes_copy_to_linear_memory( &self, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, <T as EnvBase>::Error>

Copies a slice of bytes from a Bytes object specified at offset b_pos with length len into the linear memory at position lm_pos. Traps if either the Bytes object or the linear memory doesn’t have enough bytes.
source§

fn bytes_copy_from_linear_memory( &self, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Copies a segment of the linear memory specified at position lm_pos with length len, into a Bytes object at offset b_pos. The Bytes object may grow in size to accommodate the new bytes. Traps if the linear memory doesn’t have enough bytes.
source§

fn bytes_new_from_linear_memory( &self, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Constructs a new Bytes object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn bytes_new(&self) -> Result<BytesObject, <T as EnvBase>::Error>

Create an empty new Bytes object.
source§

fn bytes_put( &self, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Update the value at index i in the Bytes object. Return the new Bytes. Trap if the index is out of bounds.
source§

fn bytes_get( &self, b: BytesObject, i: U32Val ) -> Result<U32Val, <T as EnvBase>::Error>

Returns the element at index i of the Bytes object. Traps if the index is out of bound.
source§

fn bytes_del( &self, b: BytesObject, i: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Delete an element in a Bytes object at index i, shifting all elements after it to the left. Return the new Bytes. Traps if the index is out of bound.
source§

fn bytes_len(&self, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the Bytes object.
source§

fn bytes_push( &self, b: BytesObject, u: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Appends an element to the back of the Bytes object.
source§

fn bytes_pop( &self, b: BytesObject ) -> Result<BytesObject, <T as EnvBase>::Error>

Removes the last element from the Bytes object and returns the new Bytes. Traps if original Bytes is empty.
source§

fn bytes_front(&self, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

Return the first element in the Bytes object. Traps if the Bytes is empty
source§

fn bytes_back(&self, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

Return the last element in the Bytes object. Traps if the Bytes is empty
source§

fn bytes_insert( &self, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Inserts an element at index i within the Bytes object, shifting all elements after it to the right. Traps if the index is out of bound
source§

fn bytes_append( &self, b1: BytesObject, b2: BytesObject ) -> Result<BytesObject, <T as EnvBase>::Error>

Clone the Bytes object b1, then moves all the elements of Bytes object b2 into it. Return the new Bytes. Traps if its length overflows a u32.
source§

fn bytes_slice( &self, b: BytesObject, start: U32Val, end: U32Val ) -> Result<BytesObject, <T as EnvBase>::Error>

Copies the elements from start index until end index, exclusive, in the Bytes object and creates a new Bytes from it. Returns the new Bytes. Traps if the index is out of bound.
source§

fn string_copy_to_linear_memory( &self, s: StringObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, <T as EnvBase>::Error>

Copies a slice of bytes from a String object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.
source§

fn symbol_copy_to_linear_memory( &self, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, <T as EnvBase>::Error>

Copies a slice of bytes from a Symbol object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.
source§

fn string_new_from_linear_memory( &self, lm_pos: U32Val, len: U32Val ) -> Result<StringObject, <T as EnvBase>::Error>

Constructs a new String object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn symbol_new_from_linear_memory( &self, lm_pos: U32Val, len: U32Val ) -> Result<SymbolObject, <T as EnvBase>::Error>

Constructs a new Symbol object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
source§

fn string_len(&self, s: StringObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the String object.
source§

fn symbol_len(&self, s: SymbolObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the Symbol object.
source§

fn symbol_index_in_linear_memory( &self, sym: Symbol, slices_pos: U32Val, len: U32Val ) -> Result<U32Val, <T as EnvBase>::Error>

Return the index of a Symbol in an array of linear-memory byte-slices, or trap if not found.
source§

fn compute_hash_sha256( &self, x: BytesObject ) -> Result<BytesObject, <T as EnvBase>::Error>

source§

fn verify_sig_ed25519( &self, x: BytesObject, k: BytesObject, s: BytesObject ) -> Result<Void, <T as EnvBase>::Error>

source§

fn require_auth_for_args( &self, address: AddressObject, args: VecObject ) -> Result<RawVal, <T as EnvBase>::Error>

Checks if the address has authorized the invocation of the current contract function with the provided arguments. Traps if the invocation hasn’t been authorized.
source§

fn require_auth( &self, address: AddressObject ) -> Result<RawVal, <T as EnvBase>::Error>

Checks if the address has authorized the invocation of the current contract function with all the arguments of the invocation. Traps if the invocation hasn’t been authorized.
source§

fn account_public_key_to_address( &self, pk_bytes: BytesObject ) -> Result<AddressObject, <T as EnvBase>::Error>

Converts a provided 32-byte Stellar account public key to the corresponding address. This is only useful in the context of cross-chain interoperability. Prefer directly using the Address objects whenever possible.
source§

fn contract_id_to_address( &self, contract_id_bytes: BytesObject ) -> Result<AddressObject, <T as EnvBase>::Error>

Converts a provided 32-byte contract identifier to a corresponding Address object.
source§

fn address_to_account_public_key( &self, address: AddressObject ) -> Result<RawVal, <T as EnvBase>::Error>

Returns the 32-byte public key of the Stellar account corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).
source§

fn address_to_contract_id( &self, address: AddressObject ) -> Result<RawVal, <T as EnvBase>::Error>

Returns the 32-byte contract identifier corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).
source§

fn dummy0(&self) -> Result<RawVal, <T as EnvBase>::Error>

A dummy function taking 0 arguments and performs no-op. This function is for test purpose only, for measuring the roundtrip cost of invoking a host function, i.e. host->Vm->host.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

source§

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