Replies: 5 comments
-
I don't quite get the 2nd part what you are saying, but the trait "Carrying a message" needs probably more discussion, like what's the format of that message (a string?) and who should receive it, when and how will it pass the FFI boundary? |
Beta Was this translation helpful? Give feedback.
-
Yes, sorry, a string and I would want it just like any other result, the lang layer just throws it instead. For service errors, the For example, you can't have: #[ffi_type(patterns(ffi_error))]
#[repr(C)]
pub struct CoreError<'a> {
pub message: AsciiPointer<'a>,
}
impl<'a> FFIError for CoreError<'a> {
const SUCCESS: Self = CoreError { message: <what compile-time can go here> };
const NULL: Self = CoreError { message: <what compile-time can go here> };
const PANIC: Self = CoreError { message: <what compile-time can go here> };
} There are no "FFI safe" + "const" ways to pass a message that I can find to satisfy
I can understand if not supported, just want to know what the suggested approach here is for |
Beta Was this translation helpful? Give feedback.
-
Ah, yes, this is not supported: impl<'a> FFIError for CoreError<'a> {
const SUCCESS: Self = CoreError { message: <what compile-time can go here> };
const NULL: Self = CoreError { message: <what compile-time can go here> };
const PANIC: Self = CoreError { message: <what compile-time can go here> };
} The main reason is Right now only integers (enums) support that. In your case you'd now have to, say, compare the internals of So
The way forward would be something like #40 (and the related stub #28), but that needs investigation and work. In the meantime, the only hack you could do is to give it an |
Beta Was this translation helpful? Give feedback.
-
Thanks! I think I'll have a |
Beta Was this translation helpful? Give feedback.
-
Looking to see if there's a pattern for a
FFIError
that carries a message.FFIError
requires those consts which means I can't even find a way to instantiate a compile-time struct w/AsciiPointer
(orFFIOption
or similar). Suggestions?Beta Was this translation helpful? Give feedback.
All reactions