coderfender commented on code in PR #21030: URL: https://github.com/apache/datafusion/pull/21030#discussion_r3133116633
########## datafusion/ffi/README.md: ########## @@ -65,14 +65,39 @@ to work across Rust libraries. In general, you can use Rust's [FFI] to operate across different programming languages, but that is not the design intent of this crate. Instead, we are using external crates that provide stable interfaces that closely mirror the Rust native approach. To learn more -about this approach see the [abi_stable] and [async-ffi] crates. +about this approach see the [stabby] and [async-ffi] crates. If you have a library in another language that you wish to interface to DataFusion the recommendation is to create a Rust wrapper crate to interface with your library and then to connect it to DataFusion using this crate. Alternatively, you could use [bindgen] to interface directly to the [FFI] provided by this crate, but that is currently not supported. +## Stabby Usage + +This crate uses [stabby] for ABI-stable types like `stabby::string::String` and +`stabby::vec::Vec`. We chose stabby because [abi_stable] is no longer actively +maintained. + +We intentionally use `#[repr(C)]` for our struct definitions instead of stabby's +`#[stabby::stabby]` macro. The reason is that stabby's `IStable` trait (required +by the macro) demands that all inner types also implement `IStable`. This creates +challenges for our use case: + +1. **Arrow types**: Arrow's FFI types like `FFI_ArrowSchema` do not implement + `IStable`, and adding such implementations would be laborious and error-prone. + +2. **Self-referential function pointers**: Many of our FFI structs contain + function pointers that reference `&Self`, which complicates `IStable` + implementations. Review Comment: Thanks for the clarification! Removed this point . Agree that `stabby`'s trait approach handles better than our approach here but our choice is driven by the other reasons (build time, dyn pointer complexity). Perhaps we could follow up to change this in a downstream PR ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
