uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Generate compile errors for non-lift/lowerable types

Open bendk opened this issue 1 year ago • 0 comments

We have types that can only be passed from Rust to the foreign side and vice-versa, for example flat errors, callback interfaces, etc.

Before 0.25.0, we generated an FfiConverter implementation for these types that paniced in the lift or lower method that couldn't be implemented. 0.25.0 added more granular FFI traits and we changed it so we would only implement Lower or Lift, but not the other side. This had the advantage of turning runtime errors into compile-time errors, however it caused issues when those types were nested inside compound types, so we backed it out and added back the panicing trait impls (#1847).

For 0.26.0 we should work towards a better solution. I think the best way would be to add trait bounds so that we only implemented Lift or Lower for compound types, if all of the inner types implemented Lift and Lower.

bendk avatar Nov 15 '23 18:11 bendk