Using CArgObjects in rust? #5049
-
I'm trying to write a rust library that matches an existing python API, and I'm having trouble figuring out how to correctly define my functions when they're coming from the ctypes library. The python code does something like this: def get_values(handle: HANDLE):
x = ctypes.c_uint(0)
y = ctypes.c_uint(0)
z = ctypes.c_uint(0)
status = lib.call_get_values(ctypes.byref(x), ctypes.byref(y), ctypes.byref(z))
return x,y,z and in the rust side, I need to do something like this: fn call_get_values(x: *mut u32, y: *mut u32, z: *mut u32) -> u32 {
unsafe {
*x = 1;
*y = 1;
*z = 1;
}
} and when those byref() values land in rust, they are being detected as CArgObject. I haven't been able to find a good example of how something like this would work. Any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
davidhewitt
Apr 4, 2025
Replies: 1 comment 5 replies
-
What do you mean by "detected as |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(it looks like the internals of
byref
are an implementation detail ofctypes
.)