Skip to content

Instantly share code, notes, and snippets.

@Majkl-J
Created April 22, 2025 20:46
Show Gist options
  • Save Majkl-J/465db24696afd289ba81da1b0d74605d to your computer and use it in GitHub Desktop.
Save Majkl-J/465db24696afd289ba81da1b0d74605d to your computer and use it in GitHub Desktop.
Example of including the rust-heart dll in C#
public class RustHeart
{
// Initialize our external library we use for the signal
[STAThread]
[DllImport("rustheart")]
public static extern IntPtr test_lib();
/// Freeing
[DllImport("rustheart")]
public static extern void free_rust_string(IntPtr pointer_to_clear);
[DllImport("rustheart")]
public static extern void free_runnable(IntPtr pointer_to_clear);
// Simple heart handling
[DllImport("rustheart")]
public static extern IntPtr build_simple_heart(Int64 bpm, Double amplitude);
[DllImport("rustheart")]
public static extern void simple_heart_start(IntPtr handler_pointer, UInt64 baud);
[DllImport("rustheart")]
public static extern double simple_heart_read(IntPtr handler_pointer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment