pub struct Guest;
Expand description

The Guest is the implementation of the Env interface seen and used by contracts built into WASM for execution within a WASM VM. It is a 0-sized “stub” type implementation of the Env interface that forwards each Env method to an external function, imported from its runtime environment. This implementation is automatically generated and has no interesting content.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
This one variant of logging does not take a format string and is live in both Env=Guest and Env=Host configurations.
Get the contractID Bytes of the contract which invoked the running contract. Traps if the running contract was not invoked by a contract.
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.
Get the contractID Bytes of the contract which invoked the running contract. Traps if the running contract was not invoked by a contract.
Return the protocol version of the current ledger as a u32.
Return the sequence number of the current ledger as a u32.
Return the timestamp number of the current ledger as a u64.
Return the network passphrase of the current ledger as Bytes.
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.
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.
Record a debug event. Fmt must be a Bytes. Args must be a Vec. Void is returned.
Get whether the contract invocation is from an account or another contract. Returns 0 for account, 1 for contract.
Get the AccountID object type of the account which invoked the running contract. Traps if the running contract was not invoked by an account.
Return the network id (sha256 hash of network passphrase) of the current ledger as Bytes. The value is always 32 bytes in length.
Convert a u64 to an object containing a u64.
Convert an object containing a i64 to a u64.
Convert an i64 to an object containing an i64.
Convert an object containing an i64 to an i64.
Convert the low and high 64-bit words of a u128 to an object containing a u128.
Extract the low 64 bits from an object containing a u128.
Extract the high 64 bits from an object containing a u128.
Convert the lo and hi 64-bit words of an i128 to an object containing an i128.
Extract the low 64 bits from an object containing an i128.
Extract the high 64 bits from an object containing an i128.
Create an empty new map.
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.
Get the value for a key from a map. Traps if key is not found.
Remove a key/value mapping from a map if it exists, traps if doesn’t.
Get the size of a map.
Test for the presence of a key in a map. Returns (SCStatic) TRUE/FALSE.
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).
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).
Find the minimum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
Find the maximum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).
Return a new vector containing all the keys in a map. The new vector is ordered in the original map’s key-sorted order.
Return a new vector containing all the values in a map. The new vector is ordered in the original map’s key-sorted order.
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.
Update the value at index i in the vector. Return the new vector. Trap if the index is out of bounds.
Returns the element at index i of the vector. Traps if the index is out of bound.
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.
Returns length of the vector.
Push a value to the front of a vector.
Removes the first element from the vector and returns the new vector. Traps if original vector is empty.
Appends an element to the back of the vector.
Removes the last element from the vector and returns the new vector. Traps if original vector is empty.
Return the first element in the vector. Traps if the vector is empty
Return the last element in the vector. Traps if the vector is empty
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
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.
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.
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.
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.
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.
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.
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.
Serializes an (SC)Val into XDR opaque Bytes object.
Deserialize a Bytes object to get back the (SC)Val.
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.
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.
Constructs a new Bytes object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.
Create an empty new Bytes object.
Update the value at index i in the Bytes object. Return the new Bytes. Trap if the index is out of bounds.
Returns the element at index i of the Bytes object. Traps if the index is out of bound.
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.
Returns length of the Bytes object.
Appends an element to the back of the Bytes object.
Removes the last element from the Bytes object and returns the new Bytes. Traps if original Bytes is empty.
Return the first element in the Bytes object. Traps if the Bytes is empty
Return the last element in the Bytes object. Traps if the Bytes is empty
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
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.
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.
Get the low threshold for the account with ID a (a is AccountId). Traps if no such account exists.
Get the medium threshold for the account with ID a (a is AccountId). Traps if no such account exists.
Get the high threshold for the account with ID a (a is AccountId). Traps if no such account exists.
Get the signer weight for the signer with ed25519 public key s (s is Bytes) on the account with ID a (a is AccountId). Returns the master weight if the signer is the master, and returns 0 if no such signer exists. Traps if no such account exists.
Given an ID a (a is AccountId) of an account, check if it exists. Returns (SCStatic) TRUE/FALSE.
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.
Used for recovering the concrete type of the Host.
Used to check two environments are the same, trapping if not.
Used to clone an environment deeply, not just a handle to it.
Copy a slice of bytes from the caller’s memory into an existing Bytes object the host, returning a new Bytes.
Copy a slice of bytes from a Bytes object in the host into the caller’s memory.
Form a new Bytes object in the host from a slice of memory in the caller.
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.
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.
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.
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.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.