MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new

Method new

crates/wasmtime/src/runtime/memory.rs:269–275  ·  view source on GitHub ↗

Creates a new WebAssembly memory given the configuration of `ty`. The `store` argument will be the owner of the returned [`Memory`]. All WebAssembly memory is initialized to zero. # Panics This function will panic if the [`Store`](`crate::Store`) has a [`ResourceLimiterAsync`](`crate::ResourceLimiterAsync`) (see also: [`Store::limiter_async`](`crate::Store::limiter_async`)). When using an async

(mut store: impl AsContextMut, ty: MemoryType)

Source from the content-addressed store, hash-verified

267 /// memory allocation fails. See the `OutOfMemory` type's documentation for
268 /// details on Wasmtime's out-of-memory handling.
269 pub fn new(mut store: impl AsContextMut, ty: MemoryType) -> Result<Memory> {
270 let (mut limiter, store) = store
271 .as_context_mut()
272 .0
273 .validate_sync_resource_limiter_and_store_opaque()?;
274 vm::assert_ready(Self::_new(store, limiter.as_mut(), ty))
275 }
276
277 /// Async variant of [`Memory::new`]. You must use this variant with
278 /// [`Store`](`crate::Store`)s which have a

Callers

nothing calls this directly

Calls 9

OkFunction · 0.85
wasmtime_memoryMethod · 0.80
assert_readyFunction · 0.70
newFunction · 0.50
as_context_mutMethod · 0.45
as_mutMethod · 0.45
is_sharedMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected