Calling Rust from C# with IntPtr fails on Enum (EntryPointNotFound)
<p>I'm trying to use the 'opaque pointer' style of FFI where the C# (Unity) code only sees my Rust type as an IntPtr that it has to pass around to various Rust functions. However I am getting EntryPointNotFound exceptions as soon as the function that I'm referencing refers to an enum.</p>

<p>The two functions which <em>don't</em> refer to an enum work fine, but the function that does fails to bind apparently and throws a EntryPointNotFoundException. I've included the symbols in the dynlib (bundle) file to show that the symbol is in the file.</p>

<p>I've tried without the "C" in <code>extern "C"</code> in Rust, and <code>CallingConvention=CDecl</code> and <code>CallingConvention=StdCall</code> in C# but that didn't change the situation - the int and int pointer function will run (their respective print functions indeed print), but the enum pointer function just throws EntryPointNotFoundException and "enum pointer fine" is never printed.</p>

<h2>ptr_test.rs</h2>

<pre><code>pub enum TestEnum{Test(i32)}

#[no_mangle]
pub extern "C" fn ptr_test(arg: *mut i32) {}

#[no_mangle]
pub extern "C" fn int_test(arg: i32) {}

#[no_mangle]
pub extern "C" fn consume_ptr(arg: *mut TestEnum) {}
</code></pre>

<h2>RustTest.cs</h2>

<pre><code>using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;

public class RustTest : MonoBehaviour {
    [DllImport("libptr_test")]
    private static extern void ptr_test(IntPtr x);

    [DllImport("libptr_test")]
    private static extern void int_test(int x);

    [DllImport("libptr_test")]
    private static extern void consume_ptr (IntPtr x);

    // Use this for initialization
    void Start () {
        print ("Hello World!");
        ptr_test (new IntPtr (0));
        print ("pointer fine");
        int_test (0);
        print ("int fine");
        consume_ptr (new IntPtr (0));
        print ("enum pointer fine");
        print ("Done!");
    }

    // Update is called once per frame
    void Update () {

    }
}
</code></pre>

<h2>nm -gU carved-unity/carved/Assets/libptr_test.bundle</h2>

<pre><code>...
00000000000009c0 T _consume_ptr
0000000000000990 T _int_test
0000000000000960 T _ptr_test
...
</code></pre>