Skip to content

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

@twitu

Description

@twitu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions