Rantanen / intercom

Object based cross-language FFI for Rust
MIT License
63 stars 7 forks source link

Support ComRc return values #98

Closed Rantanen closed 4 years ago

Rantanen commented 5 years ago

Currently ComResult<ComRc<T>> fails as ComRc would need a default value for type handling.

Instead of using Default::default we should define EmptyReturnValue or similar trait. We can have a blanket impl that delegates to Default::default if that is available. For other types this would allow us to implement a somewhat unsafe 'default value' for return values.

For example ComRc might instantiate ComRc that contains a null pointer. This invalidates the ComRc contract (of never being null) so implementing such Default value would be extremely unsafe - on the other hand if it is a very special EmptyReturnValue trait that is used only for (somewhat sane) uninitialized values it makes more sense.

The value() fn of that trait could also be unsafe to further mark it as being outside the usual invariants.

Rantanen commented 4 years ago

Implemented through ExternType