pub struct Instance<A: BackendApi, S: Storage, Q: Querier> { /* private fields */ }
Implementations§
Source§impl<A, S, Q> Instance<A, S, Q>
impl<A, S, Q> Instance<A, S, Q>
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.
pub fn set_debug_handler<H>(&mut self, debug_handler: H)
pub fn unset_debug_handler(&mut self)
Sourcepub fn required_capabilities(&self) -> HashSet<String>
pub fn required_capabilities(&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 instantiation to obtain this information. It’s only kept because it can be handy for integration testing.
Sourcepub fn memory_pages(&mut self) -> usize
pub fn memory_pages(&mut 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(&mut self) -> u64
pub fn get_gas_left(&mut self) -> u64
Returns the currently remaining gas.
Sourcepub fn create_gas_report(&mut self) -> GasReport
pub fn create_gas_report(&mut self) -> GasReport
Creates and returns a gas report. This is a snapshot and multiple reports can be created during the lifetime of an instance.
pub fn is_storage_readonly(&mut self) -> bool
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> Freeze for Instance<A, S, Q>
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§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.