boltffi_core 0.23.1

Core runtime types for BoltFFI - high-performance FFI bindings generator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::panic::catch_unwind;

use crate::status::FfiStatus;

pub const PANIC_STATUS: FfiStatus = FfiStatus { code: 10 };

pub fn catch_ffi_panic<F>(operation: F) -> FfiStatus
where
    F: FnOnce() -> FfiStatus + std::panic::UnwindSafe,
{
    match catch_unwind(operation) {
        Ok(status) => status,
        Err(_) => PANIC_STATUS,
    }
}