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

Method options_memory

crates/wasmtime/src/runtime/component/instance.rs:479–496  ·  view source on GitHub ↗
(
        &self,
        store: &'a StoreOpaque,
        options: OptionsIndex,
    )

Source from the content-addressed store, hash-verified

477 }
478
479 pub(crate) fn options_memory<'a>(
480 &self,
481 store: &'a StoreOpaque,
482 options: OptionsIndex,
483 ) -> &'a [u8] {
484 let memory = match self.options_memory_raw(store, options) {
485 Some(m) => m,
486 None => return &[],
487 };
488 // SAFETY: we're borrowing the entire `StoreOpaque` which owns the
489 // memory allocation to return the result of memory. That means that the
490 // lifetime connection here should be safe and the actual ptr/length are
491 // trusted parts of the runtime here.
492 unsafe {
493 let memory = memory.as_ref();
494 core::slice::from_raw_parts(memory.base.as_ptr(), memory.current_length())
495 }
496 }
497
498 pub(crate) fn options_memory_mut<'a>(
499 &self,

Callers 5

to_strMethod · 0.80
newMethod · 0.80
remaining_Method · 0.80
copyMethod · 0.80
check_boundsMethod · 0.80

Calls 4

options_memory_rawMethod · 0.80
current_lengthMethod · 0.80
as_refMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected