Rust FFI

Open-source Rust projects categorized as FFI

Top 23 Rust FFI Projects

  • PyO3

    Rust bindings for the Python interpreter

  • Project mention: Encapsulation in Rust and Python | dev.to | 2024-04-05

    Integrating Rust into Python, Edward Wright, 2021-04-12 Examples for making rustpython run actual python code Calling Rust from Python using PyO3 Writing Python inside your Rust code — Part 1, 2020-04-17 RustPython, RustPython Rust for Python developers: Using Rust to optimize your Python code PyO3 (Rust bindings for Python) Musing About Pythonic Design Patterns In Rust, Teddy Rendahl, 2023-07-14

  • Rustler

    Safe Rust bridge for creating Erlang NIF functions

  • Project mention: AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library | news.ycombinator.com | 2024-01-09

    For performance intensive tasks, you could rely on Rust NIFs, there is this great project: https://github.com/rusterlium/rustler

    My last project with Elixir was using Elixir merely as an orchestrator of static binaries (developed in golang) which were talking in JSON via stdin/stdout.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • rust-bindgen

    Automatically generates Rust FFI bindings to C (and some C++) libraries.

  • Project mention: Rust Bindgen | news.ycombinator.com | 2023-09-18
  • workers-rs

    Write Cloudflare Workers in 100% Rust via WebAssembly

  • Project mention: Python Cloudflare Workers | news.ycombinator.com | 2024-04-02

    - The speed of the Python interpreter running in WebAssembly

    Today, Python cold starts are slower than cold starts for a JavaScript Worker of equivalent size. A basic "Hello World" Worker written in JavaScript has a near zero cold start time, while a Python Worker has a cold start under 1 second.

    That's because we still need to load Pyodide into your Worker on-demand when a request comes in. The blog post describes what we're working on to reduce this — making Pyodide already available upfront.

    Once a Python Worker has gone through a cold start though, the differences are more on the margins — maybe a handful milliseconds, depending on what happens during the request.

    - There is a slight cost (think — microseconds not milliseconds) to crossing the "bridge" between JavaScript and WebAssembly — for example, by performing I/O or async operations. This difference tends to be minimal — generally something measured in microseconds not milliseconds. People with performance sensitive Workers already write them in Rust https://github.com/cloudflare/workers-rs, which also relies on bridging between JavaScript and WebAssembly.

    - The Python interpreter that Pyodide provides, that runs in WebAssembly, isn't as fast as the years and years of optimization that have gone into making JavaScript fast in V8. But it's still relatively early days for Pyodide, compared to the JS engine in V8 — there are parts of its code where we think there are big perf gains to be had. We're looking forward to upstreaming performance improvements, and there are WebAssembly proposals that help here too.

  • cbindgen

    A project for generating C bindings from Rust code

  • Project mention: Hello World in Go From Rust | dev.to | 2024-01-07

    Golang uses cgo to communicate with external C libraries and Rust uses FFI (Foreign function interfaces) to export C functions. Additionally, a library for automatically generating bindings can be used to generate the header files (.h). In our case, we'll only be exporting two C functions, so using cbindgen is overkill but we'll use it regardless because why not?  Firstly, we'll write the rust functions we want to export. We'll start by creating a new rust library:

  • rust-cpython

    Rust <-> Python bindings

  • winapi-rs

    Rust bindings to Windows API

  • Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05

    Vtables are pretty solved as well. I do a lot of Windows COM interop. Using the `windows` crate, vtables for COM interfaces are relegated to an implementation detail - instead you simply implement a (typically safe!) trait:

    https://microsoft.github.io/windows-docs-rs/doc/windows/Win3...

    Which can then be converted to a refcounted smart pointer:

    https://microsoft.github.io/windows-docs-rs/doc/windows/Win3...

    All driven by win32 sdk parsing and metadata.

    But suppose we want to roll our own, because we tend to prefer `winapi` but it lacks definition. That's not too terrible either:

    • https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...

    • https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...

    • https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...

    I could more heavily lean on my macros ala `windows`, but I went the route of manual control for better doc comments, more explicit control of thread safety traits to match the existing C++ codebase, etc.

    Is there some pointer casting? Yes. Is it annoying or likely to be what breaks? No. What is annoying?

    • Stacked borrows and narrowing spatial provenance ( https://github.com/retep998/winapi-rs/issues/1025 - this can be "solved" by sticking to pointers ala `windows`, or by choosing a different provenance model like rustc might be doing?)

    • Guarding against panics unwinding over an FFI boundary. This is at least being worked on, but remains unfinished ( https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html )

    • Edge case ABI weirdness specific to C++ methods ( https://devblogs.microsoft.com/oldnewthing/20220113-00/?p=10... , https://github.com/retep998/winapi-rs/issues/523 )

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • rinf

    Rust for native business logic, Flutter for flexible and beautiful GUI

  • Project mention: slint VS rinf - a user suggested alternative | libhunt.com/r/slint | 2024-01-24

    I really hope that people try Flutter as Rust's GUI with Rinf. Flutter doesn't involve webview, which is more like native.

  • jni-rs

    Rust bindings to the Java Native Interface — JNI

  • rust-cpp

    Embed C++ directly inside your rust code!

  • Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05

    I am the current passive maintainer of the cpp crate: https://github.com/mystor/rust-cpp

  • swift-bridge

    swift-bridge facilitates Rust and Swift interop.

  • Project mention: macOS Apps in Rust | news.ycombinator.com | 2023-05-13

    A bit late, but `swift-bridge` (https://github.com/chinedufn/swift-bridge) does this intelligently, and is probably what you're looking for.

  • magnus

    Ruby bindings for Rust. Write Ruby extension gems in Rust, or call Ruby from Rust.

  • ext-php-rs

    Bindings for the Zend API to build PHP extensions natively in Rust.

  • Project mention: Symfony 7 vs. .NET 8 - same-same but different? | dev.to | 2024-05-03

    I started with Rust a while ago. It's a beautiful language. My problem with it was the problem space it's good at addressing. I ended up not only trying to learn Rust but also wholly new paradigms related to writing low-level code, libraries, or even trying to write a PHP extension in Rust (that was way before https://github.com/davidcole1340/ext-php-rs). I learned a lot about PHP and Rust/C/PHP interoperability ;) But the learning curve was steep. In my opinion, it isn't easy to learn more than one thing simultaneously. A new language is enough. If, on top of that, you need to learn entirely new paradigms - it can be cumbersome.

  • j4rs

    Java for Rust

  • winsafe

    Windows API and GUI in safe, idiomatic Rust.

  • Project mention: Sorry... what diskette? | /r/softwaregore | 2023-07-01

    I know all that shit because I'm the author of Rust's WinSafe library, which is a safer Rust layer over native Win32, so I had to deal with a lot of shit like this.

  • jlrs

    Julia bindings for Rust

  • rust-objc

    Objective-C Runtime bindings and wrapper for Rust.

  • Project mention: macOS Apps in Rust | news.ycombinator.com | 2023-05-13
  • duckdb-rs

    Ergonomic bindings to duckdb for Rust

  • emacs-module-rs

    Rust binding and tools for Emacs's dynamic modules

  • robusta

    Easy interop between Rust and Java (by giovanniberti)

  • interoptopus

    The polyglot bindings generator for your library (C#, C, Python, …) 🐙

  • deno_bindgen

    Write high-level Deno FFI libraries in Rust.

  • Project mention: Show Reddit: Metatype - a HTTP/GraphQL query engine built with Deno and Rust | /r/Deno | 2023-05-17

    We started initially with Deno for the full engine and saw that for some of the runtimes we wanted to implement, Rust fits well thanks to https://github.com/denoland/deno_bindgen. This choice has so far paid well off and the project is now in public beta, run in production by a few companies.

  • ocaml-rs

    OCaml extensions in Rust

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020).

Rust FFI related posts

  • Symfony 7 vs. .NET 8 - same-same but different?

    1 project | dev.to | 3 May 2024
  • Encapsulation in Rust and Python

    4 projects | dev.to | 5 Apr 2024
  • Show HN: A practical example of using async Rust runtimes in C and C++

    1 project | news.ycombinator.com | 30 Mar 2024
  • Rust Bindings for the Python Interpreter

    1 project | news.ycombinator.com | 20 Feb 2024
  • Improving Interoperability Between Rust and C++

    7 projects | news.ycombinator.com | 5 Feb 2024
  • AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library

    2 projects | news.ycombinator.com | 9 Jan 2024
  • Hello World in Go From Rust

    2 projects | dev.to | 7 Jan 2024
  • A note from our sponsor - InfluxDB
    www.influxdata.com | 10 May 2024
    Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality. Learn more →

Index

What are some of the best open-source FFI projects in Rust? This list will help you:

Project Stars
1 PyO3 11,086
2 Rustler 4,164
3 rust-bindgen 4,131
4 workers-rs 2,308
5 cbindgen 2,211
6 rust-cpython 1,801
7 winapi-rs 1,803
8 rinf 1,480
9 jni-rs 1,122
10 rust-cpp 774
11 swift-bridge 730
12 magnus 591
13 ext-php-rs 534
14 j4rs 509
15 winsafe 444
16 jlrs 393
17 rust-objc 378
18 duckdb-rs 367
19 emacs-module-rs 325
20 robusta 310
21 interoptopus 288
22 deno_bindgen 262
23 ocaml-rs 249

Sponsored
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com