MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / get_handle

Method get_handle

wasm-pdk/src/lib.rs:210–217  ·  view source on GitHub ↗

Borrow the value for `name` as a raw `Handle`. Returns `Ok(None)` if absent. Use for callables, tuples, lists, dicts, anything `get:: ` can't decode.

(&self, name: &str)

Source from the content-addressed store, hash-verified

208
209 /// Borrow the value for `name` as a raw `Handle`. Returns `Ok(None)` if absent. Use for callables, tuples, lists, dicts, anything `get::<T>` can't decode.
210 pub fn get_handle(&self, name: &str) -> Result<Option<Handle>> {
211 let Some(dict) = self.0.as_ref() else { return Ok(None); };
212 let key = encode(Value::Bytes(name.as_bytes().to_vec()))?;
213 let val = dict.call("get", &[key.raw()])?;
214 let ty = val.type_of()?;
215 let ty_str = String::from_handle(ty.raw())?;
216 if ty_str == "NoneType" { Ok(None) } else { Ok(Some(val)) }
217 }
218}
219
220impl FromValue for Kwargs {

Callers 3

getMethod · 0.80
loadsFunction · 0.80
dumpsFunction · 0.80

Calls 5

BytesClass · 0.85
type_ofMethod · 0.80
encodeFunction · 0.70
callMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected