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

Require Sendable for generated Swift protocols

Open Zollerboy1 opened this issue 2 years ago • 0 comments

In the documentation about callback interfaces, it says that uniffi enables that the rust traits used for callback interfaces can require Send and Sync but that this cannot be enforced on the foreign language side. Swift has the Sendable protocol since a while now and it would be possible to require Sendable for all Swift protocols that are generated from callback interfaces. This would achieve a somewhat stronger guarantee that the callback interfaces are actually Send.

E.g. the following udl declaration:

callback interface Foo {
    i32 bar();
};

could generate this Swift code:

public protocol Foo: AnyObject, Sendable {
    func bar() -> Int32
}

Zollerboy1 avatar Jul 26 '23 12:07 Zollerboy1