Idiom - Error Handling in FFI - with structured enums in Rust #404
Answered
by
dmitri-mamrukov
dmitri-mamrukov
asked this question in
Q&A
-
Hello. I have trouble binding C structs/unions with this structured enum in https://rust-unofficial.github.io/patterns/idioms/ffi/errors.html#structured-enums That is, my question is how to implement them in C.
I've written a simplified version (with a flat enum): lib.rs
client.c
|
Beta Was this translation helpful? Give feedback.
Answered by
dmitri-mamrukov
May 13, 2024
Replies: 1 comment
-
I used cbindgen. It helped with initial code, which I manually adjusted to be close to the article's Rust code (Idiomatic Errors - Rust Design Patterns). api.h
client.c
lib.rs
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dmitri-mamrukov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used cbindgen. It helped with initial code, which I manually adjusted to be close to the article's Rust code (Idiomatic Errors - Rust Design Patterns).
api.h