<div dir="auto">If I understand you correctly you want to access fields of a rust struct using the Panama ffi.<div dir="auto">The problem is that rust doesn't have an ABI (yet). This means rust makes no guarantees about calling conventions or struct layouts.</div><div dir="auto">There are 2 ways you can access fields under these conditions. Either you mark your rust struct as #[repr(C)] or you export extern "C" getters and setters. </div><div dir="auto">Accessing rust structs without help on the rust side is impossible. This is not a shortcoming in the Java ffi but in the rust ffi.</div><div dir="auto"><br></div><div dir="auto">Great regards </div><div dir="auto">RedIODev </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 28, 2024, 07:42 Zea <<a href="mailto:zea_64@proton.me">zea_64@proton.me</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Hi,<br>I've been really excited to use this API for accessing Rust libraries, but ran into a snag.<br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Most Rust types have undefined layout, with the only properties known being size and alignment via const functions that I can export as symbols for the Java side to know ahead of time. From my understanding of the AMD64 ABI, you need to know the exact struct definition because it can sometimes pass things in registers rather than the stack, so how would I go about passing types by value (at least semantically)?</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">The best I've come up with is passing in/out pointers and memcpying those, but is this the best way? What are the JIT implications of this, if any?</div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></div><div style="font-family:Arial,sans-serif;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Thanks for helping!<br></div></blockquote></div>