pub use yog_body::*;
use yog_abi::YogStr;
use crate::registry::global_api;
pub fn track(uuid: &str, on: bool) {
let api = global_api();
if api.is_null() {
return;
}
unsafe { ((*api).client_body_track)((*api).ctx, YogStr::from_str(uuid), on) }
}
pub fn entity_data(uuid: &str, key: &str) -> Option<Vec<u8>> {
let api = global_api();
if api.is_null() {
return None;
}
let mut out = Vec::new();
let found = unsafe {
((*api).client_entity_data)((*api).ctx, YogStr::from_str(uuid), YogStr::from_str(key), &mut out as *mut Vec<u8> as *mut std::os::raw::c_void, collect)
};
found.then_some(out)
}
pub(crate) unsafe extern "C" fn collect(sink: *mut std::os::raw::c_void, data: *const u8, len: usize) {
unsafe { (*(sink as *mut Vec<u8>)).extend_from_slice(std::slice::from_raw_parts(data, len)) }
}
pub fn set_dimensions(uuid: &str, size: Option<(f32, f32, f32)>) {
let api = global_api();
if api.is_null() {
return;
}
let (w, h, e) = size.unwrap_or((-1.0, 0.0, 0.0));
unsafe { ((*api).client_set_dimensions)((*api).ctx, YogStr::from_str(uuid), w, h, e) }
}
pub fn track_type(entity_type: &str, on: bool) {
let api = global_api();
if api.is_null() {
return;
}
unsafe { ((*api).client_body_track_type)((*api).ctx, YogStr::from_str(entity_type), on) }
}