Struct cosmwasm_vm::Instance
source · [−]pub struct Instance<A: BackendApi, S: Storage, Q: Querier> { /* private fields */ }
Implementations
sourceimpl<A, S, Q> Instance<A, S, Q> where
A: BackendApi + 'static,
S: Storage + 'static,
Q: Querier + 'static,
impl<A, S, Q> Instance<A, S, Q> where
A: BackendApi + 'static,
S: Storage + 'static,
Q: Querier + 'static,
sourcepub fn from_code(
code: &[u8],
backend: Backend<A, S, Q>,
options: InstanceOptions,
memory_limit: Option<Size>
) -> VmResult<Self>
pub fn from_code(
code: &[u8],
backend: Backend<A, S, Q>,
options: InstanceOptions,
memory_limit: Option<Size>
) -> VmResult<Self>
This is the only Instance constructor that can be called from outside of cosmwasm-vm, e.g. in test code that needs a customized variant of cosmwasm_vm::testing::mock_instance*.
pub fn api(&self) -> &A
sourcepub fn recycle(self) -> Option<Backend<A, S, Q>>
pub fn recycle(self) -> Option<Backend<A, S, Q>>
Decomposes this instance into its components. External dependencies are returned for reuse, the rest is dropped.
sourcepub fn required_features(&self) -> HashSet<String>
pub fn required_features(&self) -> HashSet<String>
Returns the features required by this contract.
This is not needed for production because we can do static analysis on the Wasm file before instatiation to obtain this information. It’s only kept because it can be handy for integration testing.
sourcepub fn memory_pages(&self) -> usize
pub fn memory_pages(&self) -> usize
Returns the size of the default memory in pages. This provides a rough idea of the peak memory consumption. Note that Wasm memory always grows in 64 KiB steps (pages) and can never shrink (https://github.com/WebAssembly/design/issues/1300#issuecomment-573867836).
sourcepub fn get_gas_left(&self) -> u64
pub fn get_gas_left(&self) -> u64
Returns the currently remaining gas.
sourcepub fn create_gas_report(&self) -> GasReport
pub fn create_gas_report(&self) -> GasReport
Creates and returns a gas report. This is a snapshot and multiple reports can be created during the lifetime of an instance.
sourcepub fn set_storage_readonly(&mut self, new_value: bool)
pub fn set_storage_readonly(&mut self, new_value: bool)
Sets the readonly storage flag on this instance. Since one instance can be used for multiple calls in integration tests, this should be set to the desired value right before every call.
pub fn with_storage<F: FnOnce(&mut S) -> VmResult<T>, T>(
&mut self,
func: F
) -> VmResult<T>
pub fn with_querier<F: FnOnce(&mut Q) -> VmResult<T>, T>(
&mut self,
func: F
) -> VmResult<T>
Auto Trait Implementations
impl<A, S, Q> !RefUnwindSafe for Instance<A, S, Q>
impl<A, S, Q> Send for Instance<A, S, Q>
impl<A, S, Q> Sync for Instance<A, S, Q>
impl<A, S, Q> Unpin for Instance<A, S, Q> where
A: Unpin,
impl<A, S, Q> !UnwindSafe for Instance<A, S, Q>
Blanket Implementations
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more