Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate returning Kotlin style Result type through JNI bindings. #74

Open
twitu opened this issue Jun 15, 2024 · 0 comments
Open

Investigate returning Kotlin style Result type through JNI bindings. #74

twitu opened this issue Jun 15, 2024 · 0 comments

Comments

@twitu
Copy link
Collaborator

twitu commented Jun 15, 2024

JNI does not support returning the generic types so Result<T> cannot be returned from bindings. JNI bindings can only return Java values. The solution implemented in #61 throws exception when a result type is an error. However, there might be a way to return Kotlin/functional style Result values from JNI bindings which will give a more ergonomic API.

Since JNI only allows Java types a Kotlin Result type is not supported directly. However, it is possible to create a Java Result class that mimics a Kotlin Result type.1 To use this it will need to be defined and loaded into the JNIEnv2 so that the Java Result object can be created and filled with the appropriate value.

The result will be a more ergonomic and functional style Java bindings to the fs-storage crate.

Footnotes

  1. https://stackoverflow.com/q/60626607

  2. https://stackoverflow.com/q/67818417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant