Rust Object Storage Plugin

Hello everyone,

finally got round to finding some spare side-project time and wanted to share this showcase for anyone interested.

The sample shows change notifications and implements S3 storage as a “StorageArea”. Integration is performed using the C/C++ SDK.

https://github.com/andrewwebber/orthanc-rust-plugins

Apologies in advance if the README is lacking.

kind regards,

Andrew

orthanc_s3.png

Dear Andrew,

This is a great achievement! Thanks for sharing!

I have just indexed your plugin in the Orthanc Book:

https://book.orthanc-server.com/plugins.html#rust-plugins

I would look forward to a talk about this topic at the next edition of the Orthanc conference :wink:

Regards,
Sébastien-

Hi Andrew,
That’s very interesting. May I ask that the RUST code is binded into the C++ order it is compiled to native lib which is compatible with C++ ?

Hi tdpar…,

The Rust code must first be complied to a system dynamic library

  • –crate-type=cdylib, #![crate_type = “cdylib”] - A dynamic system library will be produced. This is used when compiling a dynamic library to be loaded from another language. This output type will create *.so files on Linux, *.dylib files on macOS, and *.dll files on Windows.

The Rust code is actually loaded dynamically into memory by Orthanc via the plugin architecture.
https://hg.orthanc-server.com/orthanc/file/tip/OrthancFramework/Sources/SharedLibrary.cpp#l47

The Rust plugin only needs to be compiled with a C runtime version that matches the same C runtime version used by the Orthanc installation.

For example on an ubuntu machine:
ldd --version
ldd (Ubuntu GLIBC 2.31-0ubuntu9.9) 2.31

On an Arch Linux machine:
ldd --version
ldd (GNU libc) 2.36

kind regards,

Andrew

Hi Andrew,

Thanks for sharing! I had attempted a simple plugin before, but Rust FFI is not for the uninitiated, I learned quite a lot when checking out your code.

Am I correct in assuming the bindgen approach could be extended into a base library that would allow others to create pure (safe) Rust plugins?

Regards
Walco

Hi Walco,

I updated the sample to use a public dependency which contains the pre-generated bindings.
https://crates.io/crates/orthanc-plugin-bindings

This should hopefully make plugin development easier for you.

As shown below one can simply add this dependency.

[dependencies]
orthanc-plugin-bindings = “0.1”

kind regards,

Andrew

Hi Andrew,

Thanks a lot! I will try it out and see if I can expand on it. Would be great to gain the possibility of creating pure Rust plugins with an idiomatic API.

Regards
Walco