rust-dlopen
A long time ago in a dirty basement far, far away a programmer was trying to dynamically load a library using standard C API (because he didnt know Rust yet):
/* Open a dynamic library, get function, use it and then close the library ... */
//Problem: this is Unix API, won't work on Windows
void
Basically use of dynamic link libraries is extremely prone to errors and requires a lot of coding to perform even the simplest operations.
This library aims to simplify the process of developing APIs for dynamically loaded libraries in Rust language and to reduce number of mistakes (please note that you can't create any library that is 100% safe because loading libraries requires transmutation of obtained pointers).
Main features
- Supports majority of platforms and is platform independent.
- Is consistent with Rust error handling mechanism and makes making mistakes much more difficult.
- Is very lightweight. It mostly uses zero cost wrappers to create safer abstractions over platform API.
- Is thread safe.
- Is object-oriented programming friendly.
- Has a low-level API that provides full flexibility of using libraries.
- Has two high-level APIs that protect against dangling symbols - each in its own way.
- High level APIs support automatic loading of symbols into structures. You only need to define a structure that represents an API. The rest happens automatically and requires only minimal amount of code.
Usage:
Cargo.toml:
[]
= "0.1"
License
This code is licensed under MIT license.