Crate soroban_env_host
source ·Expand description
This crate mainly exists to provide the Soroban Host type, which is the implementation of the Env interface between guest contract code and the host it runs within.
This crate also re-exports all of the content of the soroban_env_common crate for use by host (or contract local-testing) code. Most of the type and module definitions visible here are actually defined in the common crate.
The Host
can be configured with or without support for a vm::Vm,
depending on the "vm"
cargo feature. When enabled, the VM is currently a
thin wrapper around the wasmi
interpreter, though other VMs might be supported in the future.
It may seem unusual to configure a contract host without a VM, but this
configuration makes more sense when considering that Soroban supports a
“local testing” configuration where host and guest code are both compiled
natively and linked together for a faster and richer debugging and testing
experience. When testing this way, developers may also wish to enable the
"testutils"
feature, which enables an interface on Host for registering
other test contracts by ID.
The Host type provides some facilities above and beyond just the Env trait, including:
Re-exports
pub use vm::Vm;
Modules
- This module contains version constants (and other metadata) that are embedded in binaries (especially WASM binaries) compiled against a particular version of this crate. Versioning at this level provides an early diagnostic check for compatibility between a loaded WASM binary and the Env interface provided by the host, rather than a cryptic failure due to a runtime host function signature mismatch.
- Library and CLI containing types and functionality for working with Stellar XDR.
Macros
Structs
- Error type indicating a failure to convert some type to another; details of the failed conversion will typically be written to the debug log.
- A 256-bit signed integer type.
ScValObject
(and its reference-based typeScValObjRef
) is a small wrapper type that does not have its own XDR definition, it just denotes (as a type) the subset ofScVal
values that need to be represented inRawVal
by one of the cases that can be anObject
. In other wordsRawVal::try_from_val(&v, e).is_object()
will be true iffScValObject::classify(v)
isOk(ScValObject(v))
.- Wrapper for a RawVal that is tagged with [Tag::Status], interpreting the RawVal’s body as a pair of a 28-bit status-type code and a 32-bit status code. The status-type codes correspond to the enumerated cases of ScStatusType, and the status codes correspond to the code values stored in each variant of the ScStatus union.
- An iterator that decodes the individual bit-packed characters from a symbol and yields them as regular Rust char values.
- A 256-bit unsigned integer type.
- A dummy implementation of the Env trait that fails with
unimplemented!()
in all functions. Useful for certain testing scenarios. - The VmCallerEnv trait is similar to the Env trait – it provides all the same-named methods – but they have a form that takes an initial
VmCaller
argument by&mut
that may or may-not wrap awasmi::Caller
structure, depending on whether it was invoked from a wasmi host-function wrapper.
Enums
- Errors related to operations on the SymbolObject and SymbolSmall types.
- Code values for the 8
tag
bits in the bit-packed representation of RawVal. These don’t coincide with tag numbers in the SCVal XDR but cover all those cases as well as some optimized refinements for special cases (boolean true and false, small-value forms).
Constants
Traits
- General trait representing the ability to compare two values of some type. Similar to
core::cmp::Cmp
but with two key differences: the comparison is fallible, and is provided by some external type implementingCompare
rather than the compared type itself. - General trait representing a the ability of some object to perform a (possibly unsuccessful) conversion between two other types.
- Base trait extended by the Env trait, providing various special-case functions that do not simply call across cross the guest/host interface.