13

Mozilla has the Oxidation project:

The goal of Oxidation is to make it easier and more pleasant to use Rust in Firefox, and correspondingly to increase the amount of Rust code in Firefox.

But it does not mention anything about whether Rust is supported for add-ons or not.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
typo
  • 359
  • 3
  • 10
  • Related: https://stackoverflow.com/questions/851109/what-programming-language-required-to-created-a-firefox-plugin – MB-F Aug 09 '18 at 11:27
  • Hum, I doubt that Rust would be an user-friendly way to write add-ons. There is no Rust ABI, so you have to use the C ABI with FFI. Related: https://stackoverflow.com/questions/44708483/idiomatic-rust-plugin-system/44715785 – Boiethios Aug 09 '18 at 12:01
  • 2
    Maybe you can write them in rust and compile them to WebAsm. But i dont know if WebExtensions support WebAsm. – gotocoffee Aug 09 '18 at 13:47
  • @Boiethios There is no C ABI, it's the Operating system ABI if you want but C same as Rust don't define their ABI in their specification. – Stargateur Aug 09 '18 at 15:14
  • @gotocoffee If it does not, you should bring up the idea because it is a nice one! – Boiethios Aug 09 '18 at 15:16

2 Answers2

12

Nowadays, you can do with WebExtensions and WebAssembly (guide how to compile here). You then just embed it as wasm code in your add-on like in any website.

This add-on e.g. did so. (found on reddit)

rugk
  • 4,755
  • 2
  • 28
  • 55
3

I don't think it is possible to write a complete add-on in Rust. Although you could use Native Messaging to communicate from the add-on to a binary built with Rust. When an add-on uses native messaging the browser starts a native binary on the system and exchanges messages encoded in JSON over stdio.

Mozilla has detailed information about native messaging on MDN.

Wes
  • 2,166
  • 1
  • 20
  • 22