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

Rust Bindings #2730

Open
PhilippGackstatter opened this issue May 28, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@PhilippGackstatter
Copy link
Contributor

commented May 28, 2019

Starting roughly in the middle of July, I would like to implement Rust bindings for Elektra.

I think that rust-bindgen should be able to automatically generate (some or all of) the bindings. I still expect there to be quite a bit of manual work to get them working properly. From my current understanding and from @kodebach's comment, this will result in a elektra-sys crate.
Once it is working I'll add a safe API in Rust, so that it can be used in regular Rust without the need to call unsafe code. This will then be the elektra crate.
I'll then make sure that they are correct by testing with cargo tests.

The typical way to document crates is with comments in the code. docs.rs will automatically build the documentation and make it publicly available, so I think doing documentation this way makes the most sense.

To publish the crate to crates.io, an account with an API token is needed. As discussed with @markus2330, this account should be part of ElektraInitiative such that it is accessible to future maintainers.

I'll look at the CMake integration at the start of the project, since I'm not familiar with CMake at the moment.

Is there anything else I should add?

@kodebach

This comment has been minimized.

Copy link
Contributor

commented May 28, 2019

I don't know that much about Rust, but I suppose that the bindings generated by rust-bindgen can only be used in unsafe Rust? If that is the case, it would be nice to have a wrapper around those with a more idiomatic Rust API.

AFAIK most Rust binding have one *-sys crate for the 1:1 mapping of the C API and another crate with the API that most users would actually use in Rust. If there is a way to tell Rust to automatically invoke keyDel, ksDel and friends when necessary that would be really nice.

@markus2330

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

If that is the case, it would be nice to have a wrapper around those with a more idiomatic Rust API.

Yes, this is the plan. And while doing so, also compare with the C API and maybe find improvements in the C API (at least in the docu).

@PhilippGackstatter As discussed: Please also find out how to upload to https://crates.io/ and how to integrate the binding in our CMake system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.