Compile to and interoperate with Adobe AIR

I've asked sometimes here, but I want more feedback on an idea.

I'm aware of the wasm2swf tool which converts WebAssembly to ActionScript bytecode and SWF, possibly allowing to use Rust instead of ActionScript.

I'll need more than wasm2swf. I don't want to use the Loader class too as the wasm2swf example uses to invoke Rust code. Since the goal is to reuse the ActionScript API, I think I could remove std as dependency. Is it possible to depend on nothing from Rust's built-ins (std, etc.)?

For example, I want to use the ActionScript String type. I want it with Copy + PartialEq and more traits. How would I go on properly allowing Rust to interoperate with the Adobe AIR ecosystem?

Can I remove, say, std, from a Cargo project?

Yes, with the #![no_std] attribute. This is common on embedded devices without an OS.


Another question: Is it possible for the string literal ("string", aka. &'static str) to return, say, actionscript::global::String? I suppose it involves using extern something.

I just wanted this to work:

use actionscript::global::*;

let s: String = "some str";

// rather than

let s: &'static str = "some str";

Is String::from("some str") all I can do? (And s.into() where possible)

let s = String::from("abc");

// inference = use .into

fn f(s: String) {
    // procedure


No, it's not possible. String literals are always &'static str.


You can instead take impl Into<String> to make the call a bit cleaner, at least.

1 Like

I still didn't want to use wasm2swf nor did I want to convert myself the rustc's generated .wasm to SWF. I think that Rust compiled to WebAssembly "loses" all information, such as what's the type of a variable.

I think that both the LLVM bitcode or IR and WebAssembly outputs of Rust aren't ideal, because they generated low-level code. I need to compile Rust to a high-level format that I can easily compile to AVM2 bytecode.

I could use the Rust compiler API for achieving what I want, but then I'll lose all of the existing IDE support (including rust-analyzer)?

Is there a way to build a Rust or Cargo project to a kind of high-level bytecode?

Possibly I'm looking for the Rust's HIR? The HIR (High-level IR) - Rust Compiler Development Guide

Found what you mean by that sentence. You created a topic on IRLO a while back:

I'm linking this so people interested in this thread have some more context.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.