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)
| 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 | |
| 220 | impl FromValue for Kwargs { |