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

Vector containing user-defined structs #21

Open
HagaiHargil opened this issue Sep 4, 2018 · 0 comments
Open

Vector containing user-defined structs #21

HagaiHargil opened this issue Sep 4, 2018 · 0 comments

Comments

@HagaiHargil
Copy link

Hello and thanks for milksnake!

I'm having issues using the package when I wish to run a Rust function that returns a vector of tuples. I'm basically trying to replicate Shepmaster's excellent SO answer since my use case is very similar, but simpler - I don't wish to both send and receive a vector of tuples from Python, I only wish to receive one back.

When I build his code using milksnake with the slight change I just mentioned, everything compiles successfully, and I even receive my vector back. Unfortunately, Python thinks it's an Array type, which is the name of the user-defined type in Rust, and I can't find a way to "dereference" it into a standard Python list. milksnake doesn't directly expose user-defined Rust types like Array, and I'm not sure which magic tricks I should envoke from ctypes to make it work. The object I receive is the following:

arr = lib.convert_vec()
print(arr.data)  # <cdata 'void *' 0x00000282F3D28160>
print(arr.size)  # 7 (works)

Thanks!

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