Get the latest tech news

Building a dynamic lib plugin system for Rust


Software used by businesses often needs to be extensible. For Arroyo, a real-time SQL engine, that means supporting user-defined functions (UDFs). But how can we support dynamic, user-written code in a static language like Rust? This post dives deep into the technical details of building a dynamically-linked, FFI-based plugin system in Rust.

At this point I'd like to introduce an extremely helpful resource for anyone straying from the cosy, warm cottage of safe Rust and out into the deep dark night of unsafe: the Rustonomicon. (In a real system, you'd likely want a few more components, including a common library to share definitions between the plugin and host, and a macro to do code generation, but we're keeping this relatively simple.) Making your users write all of this unsafe boilerplate for every plugin isn't great UX, so you may want to use a macro or just wrapper code (if you don't need to support multiple types).

Get the Android app

Or read this on Hacker News

Read more on:

Photo of System

System

Photo of Rust

Rust

Photo of plugin

plugin

Related news:

News photo

Counting words in Python, Go, C++, C, Awk, Forth, and Rust (2021)

News photo

in Rust, methods should be object safe

News photo

Dioxus S23 is hiring a cracked founding engineer (Rust)