Function interoptopus::patterns::success_enum::panics_and_errors_to_ffi_enum[][src]

pub fn panics_and_errors_to_ffi_enum<E, FE: Success>(
    f: impl FnOnce() -> Result<(), E>
) -> FE where
    FE: From<Result<(), E>>, 
Expand description

Helper to transform Result types to Success enums inside extern "C" functions.

This function executes the given closure f. If f returns Ok(()) the SUCCESS variant is returned. On a panic or Err the respective error variant is returned instead.

Safety

Once Success::PANIC has been observed the enum’s recipient should stop calling this API (and probably gracefully shutdown or restart), as any subsequent call risks causing a process abort.