use crate::handle::ErrorHandle;
#[no_mangle]
pub unsafe extern "C" fn eggfetch_error_free(handle: *mut ErrorHandle) {
crate::ffi_guard!((), {
if !handle.is_null() {
drop(Box::from_raw(handle));
}
});
}
#[no_mangle]
pub unsafe extern "C" fn eggfetch_error_kind(
handle: *const ErrorHandle,
) -> *mut std::os::raw::c_char {
crate::ffi_guard!(std::ptr::null_mut(), {
let Some(handle) = handle.as_ref() else {
return std::ptr::null_mut();
};
crate::handle::FfiString::from_string(handle.kind.clone())
.map_or_else(std::ptr::null_mut, crate::handle::FfiString::into_raw)
})
}
#[no_mangle]
pub unsafe extern "C" fn eggfetch_error_message(
handle: *const ErrorHandle,
) -> *mut std::os::raw::c_char {
crate::ffi_guard!(std::ptr::null_mut(), {
let Some(handle) = handle.as_ref() else {
return std::ptr::null_mut();
};
crate::handle::FfiString::from_string(handle.message.clone())
.map_or_else(std::ptr::null_mut, crate::handle::FfiString::into_raw)
})
}
#[no_mangle]
pub unsafe extern "C" fn eggfetch_error_is_error(handle: *const ErrorHandle) -> i32 {
crate::ffi_guard!(0, { i32::from(!handle.is_null()) })
}