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

Method get

crates/wasi-common/src/table.rs:70–77  ·  view source on GitHub ↗

Get an Arc reference to a resource of a given type at a given index. Multiple immutable references can be borrowed at any given time.

(&self, key: u32)

Source from the content-addressed store, hash-verified

68 /// Get an Arc reference to a resource of a given type at a given index. Multiple
69 /// immutable references can be borrowed at any given time.
70 pub fn get<T: Any + Send + Sync + Sized>(&self, key: u32) -> Result<Arc<T>, Error> {
71 if let Some(r) = self.0.read().unwrap().map.get(&key).cloned() {
72 r.downcast::<T>()
73 .map_err(|_| Error::badf().context("element is a different type"))
74 } else {
75 Err(Error::badf().context("key not in table"))
76 }
77 }
78
79 /// Get a mutable reference to a resource of a given type at a given index.
80 /// Only one such reference can be borrowed at any given time.

Callers 8

write_to_guestMethod · 0.45
get_fileMethod · 0.45
isMethod · 0.45
get_dirMethod · 0.45
fd_fdstat_getMethod · 0.45
fd_fdstat_set_rightsMethod · 0.45
fd_prestat_getMethod · 0.45
fd_prestat_dir_nameMethod · 0.45

Calls 3

unwrapMethod · 0.45
readMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected