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

Use C structs/tagged unions for Records/Enums

Open bendk opened this issue 1 year ago • 2 comments

Currently these types are always serialized into a RustBuffer which has been long believed to be inefficient (Issue 244, ADR-002). We should explore passing these as repr(C) structs and tagged unions to avoid the overhead of serialization and allocating a buffer.

These could either be passed across the FFI as a pointer/reference or as the struct directly. Some of the recent changes could help here, for example we now have both FfiType::Struct and FfiType::Reference.

Any change here should be accompanied by a benchmark that measures performance changes.

bendk avatar Jun 17 '24 21:06 bendk