Rust and dynamic loading of code

Hi there Rusteceans! I'm wondering is it possible for rust to support dynamic load of crates/modules/traits? Basically what I'm looking for Rust's analogue of JDBC, where you can say ok implement this interface and I'll load you during runtime.

It's possible but not supported. The compiler itself has plugins. The plugin loading is done here: http://manishearth.github.io/rust-internals-docs/src/rustc/plugin/load.rs.html#106-142

It uses the dynamic_lib crate: http://manishearth.github.io/rust-internals-docs/std/dynamic_lib/index.html

Be aware that this is highly unstable code and may change and break your code at any time.

2 Likes