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 )

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS 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: PHP-Tokio – Use any async Rust library from PHP | news.ycombinator.com | 2023-08-27

    The PHP <-> Rust bindings are provided by https://github.com/Nicelocal/ext-php-rs/ (our fork of https://github.com/davidcole1340/ext-php-rs with a bunch of UX improvements :).

    php-tokio's integrates the https://revolt.run event loop with the https://tokio.rs event loop; async functionality is provided by the two event loops, in combination with PHP fibers through revolt's suspension API (I could've directly used the PHP Fiber API to provide coroutine suspension, but it was a tad easier with revolt's suspension API (https://revolt.run/fibers), since it also handles the base case of suspension in the main fiber).

  • 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). The latest post mention was on 2024-04-05.

Rust FFI related posts

Index

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

Project Stars
1 PyO3 10,947
2 Rustler 4,152
3 rust-bindgen 4,055
4 workers-rs 2,262
5 cbindgen 2,182
6 rust-cpython 1,798
7 winapi-rs 1,786
8 rinf 1,436
9 jni-rs 1,105
10 rust-cpp 771
11 swift-bridge 692
12 magnus 576
13 ext-php-rs 527
14 j4rs 501
15 winsafe 437
16 jlrs 393
17 rust-objc 378
18 duckdb-rs 357
19 emacs-module-rs 320
20 robusta 305
21 interoptopus 283
22 deno_bindgen 259
23 ocaml-rs 249
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com