Just saying "no" and repeating your question without further clarification doesn't help. What are you trying to unwrap and from what? Like, what's your goal from input/output standpoint?
Well, as far as I understand your question I would tent to say this is not possible in Rust, as a function signature can only return one specific type and not one type in one case and a complete other type on the other hand.
You could overcome this situation if you would define a trait that both your return value variants implement and than using a trait object as the return type.
I'm not quite certain what you're asking but I would recommend putting your actual logic in a Rust function since it makes it easier and then convert to FFI types at the top level:
extern "C" fn extern_fn() -> Status {
inner_fn.map(|_| Status::OK).unwrap_or(Status::ERROR)
}
fn inner_fn() -> Result<(), ()> {
// Any code
option_my_enum.ok(())?;
// Any code
Ok(())
}
I am not sure if this is what you want, because in your first example you showed you intended to return either the enum or the error, but that is not what your second example is doing.
If you intend to something similar to your first example, you have to remember that you need to return something valid in C, like the following: