|
|
|
|
@ -605,6 +605,20 @@ pub unsafe extern "C" fn jb_set_string(
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn jb_set_string_from_bytes(
|
|
|
|
|
js: &mut JsonBuilder, key: *const c_char, bytes: *const u8, len: u32,
|
|
|
|
|
) -> bool {
|
|
|
|
|
if bytes == std::ptr::null() || len == 0 {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if let Ok(key) = CStr::from_ptr(key).to_str() {
|
|
|
|
|
let val = std::slice::from_raw_parts(bytes, len as usize);
|
|
|
|
|
return js.set_string_from_bytes(key, val).is_ok();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn jb_set_jsont(
|
|
|
|
|
jb: &mut JsonBuilder, key: *const c_char, jsont: &mut json::JsonT,
|
|
|
|
|
@ -641,6 +655,17 @@ pub unsafe extern "C" fn jb_append_string(js: &mut JsonBuilder, val: *const c_ch
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn jb_append_string_from_bytes(
|
|
|
|
|
js: &mut JsonBuilder, bytes: *const u8, len: u32,
|
|
|
|
|
) -> bool {
|
|
|
|
|
if bytes == std::ptr::null() || len == 0 {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let val = std::slice::from_raw_parts(bytes, len as usize);
|
|
|
|
|
return js.append_string_from_bytes(val).is_ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn jb_append_uint(js: &mut JsonBuilder, val: u64) -> bool {
|
|
|
|
|
return js.append_uint(val).is_ok();
|
|
|
|
|
|