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

Discussion: Creating a C Interface #399

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

meggart
Copy link

@meggart meggart commented Nov 19, 2024

This is my first attempt of a proof-of-concept Rust -> C -> Julia roundtrip that was discussed in #381 where I just wrapped the first function calls of the basic example that create a repository and adds some groups. Whoever is interested, maybe you can have a quick look and let me know your opinions. A C header file is generated, but currently the c wrapper in icechunk-julia is manually generated. Of course, if one wants to roll out a full c lib for the storage interface there would be a few design decisions to make. The most burning questions I would have are the following:

  1. To what extent would one expose rust structs through the C API as well. For example things like RepositoryConfig could be marked with [repr(C)] to get C memory layout which would make sharing them much more convenient. In the end only things wrapped in Arcs actually need to be hidden behind opaque pointers.
  2. Some system of automated error code translation would be nice, in the example here I only return a generic -1 in case of any error
  3. Also important to note that any panic on the rust side leads to a segmentation fault on the caller side, to it is crucial to carefully unwrap every result
  4. In this example I use calls to block_on to get out of the async machinery. However I have no idea how this would interact if a calling site actually tried to perform async calls into the library (probably it would just break?)

@rabernat
Copy link
Contributor

@meggart - just wanted to drop a note to say THANK YOU for working on this. We are planning to give you some feedback very soon.

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

Successfully merging this pull request may close these issues.

2 participants