# Rust Object Storage Plugin

**URL:** https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141
**Category:** Google Groups archive
**Created:** [November 21, 2022, 9:14pm UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141 "2022-11-21T21:14:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Andrew\_Webber](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Andrew\_Webber](https://discourse.orthanc-server.org/u/Andrew_Webber)
#### Post date: [November 21, 2022, 9:14pm UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/1 "2022-11-21T21:14:46Z")

</div>

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](https://github.com/andrewwebber/orthanc-rust-plugins)

Apologies in advance if the README is lacking.

kind regards,

Andrew

![orthanc_s3.png](https://discourse.orthanc-server.org/uploads/default/original/1X/c7c9c021cebb99704ee62d9348bc70463f298133.png)

---

<div class="post-metadata">

### Author: ![jodogne](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/jodogne/32/1511_2.png) [@jodogne](https://discourse.orthanc-server.org/u/jodogne)
#### Post date: [November 23, 2022, 5:51pm UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/2 "2022-11-23T17:51:06Z")

</div>

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](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 😉

Regards,  
Sébastien-

---

<div class="post-metadata">

### Author: ![Christopher](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/c/439d5e/32.png) [@Christopher](https://discourse.orthanc-server.org/u/Christopher)
#### Post date: [November 25, 2022, 10:00am UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/3 "2022-11-25T10:00:43Z")

</div>

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++ ?

---

<div class="post-metadata">

### Author: ![Andrew\_Webber](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Andrew\_Webber](https://discourse.orthanc-server.org/u/Andrew_Webber)
#### Post date: [November 25, 2022, 11:25am UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/4 "2022-11-25T11:25:03Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![walco](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/w/c77e96/32.png) [@walco](https://discourse.orthanc-server.org/u/walco)
#### Post date: [November 25, 2022, 12:01pm UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/5 "2022-11-25T12:01:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Andrew\_Webber](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Andrew\_Webber](https://discourse.orthanc-server.org/u/Andrew_Webber)
#### Post date: [November 26, 2022, 9:17pm UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/6 "2022-11-26T21:17:11Z")

</div>

Hi Walco,

I updated the sample to use a public dependency which contains the pre-generated bindings.  
[https://crates.io/crates/orthanc-plugin-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

---

<div class="post-metadata">

### Author: ![walco](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/w/c77e96/32.png) [@walco](https://discourse.orthanc-server.org/u/walco)
#### Post date: [November 30, 2022, 7:51am UTC](https://discourse.orthanc-server.org/t/rust-object-storage-plugin/3141/7 "2022-11-30T07:51:05Z")

</div>

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
