Skip to main content

haystack_value_get_dict_entry

Function haystack_value_get_dict_entry 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn haystack_value_get_dict_entry( val: *mut Value, key: *const c_char, result: *mut *const Value, ) -> ResultType
Expand description

Get the element of a Dict Value by the key

§Arguments

  • val A Dict Value
  • result The Value to be updated.

§Returns

  • 1 (True) if the operation was successful, 0 (false) if no element found, -1 otherwise in which case the last_error_message can be called to get the error message.

§Example

let val = haystack_value_make_dict();
assert!(haystack_value_is_dict(val));
let key = std::ffi::CString::new("equip").unwrap();
haystack_value_insert_dict_entry(val, key.as_ptr(), entry);
assert_eq!(haystack_value_get_dict_len(val), 1);
let mut result = std::ptr::null();
assert_eq!(haystack_value_get_dict_entry(val, key.as_ptr(), &mut result), ResultType::TRUE);
assert_eq!(&*result, entry);

§Safety

Panics on invalid input data