getsentry / getsentry/milksnake

Vector containing user-defined structs

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
805
Forks
34
PR merge metrics
No merged PRs in 30d

Description

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](https://stackoverflow.com/questions/30984688/convert-rust-vector-of-tuples-to-a-c-compatible-structure) 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:
```python
arr = lib.convert_vec()
print(arr.data) #
print(arr.size) # 7 (works)
```
Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.