Changed auth_type to an i32 to make it easier to pass across the FFI boundary. Also changed a return type to a String for the same reason.
Depends on D4933
Differential D4934
[native] change params and types to satisfy cxx requirements varun on Aug 23 2022, 10:43 PM. Authored by Tags None Referenced Files
Details Changed auth_type to an i32 to make it easier to pass across the FFI boundary. Also changed a return type to a String for the same reason. Depends on D4933 cargo build
Diff Detail
Event TimelineComment Actions
Is it a good practice to use i32 instead of enum? How hard is it to pass an enum?
Comment Actions It's not a great practice but it's hard to pass an enum. If the enum is defined in the ffi module, the compiler complains: non-primitive cast: `ffi::AuthType` as `i32` an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object And if I try to define it in the Rust library, the compiler complains about passing opaque Rust types by value. I can explore a better solution and revisit this later, if that works for you.
Comment Actions Yeah, a small research sounds like a good idea. The safer we make this code, the less problems we will have in the future. A quick search gave me this https://rust-lang.github.io/unsafe-code-guidelines/layout/enums.html#repr-annotations-accepted-on-enums - not sure, but it might be helpful.
|