Rust
When talking about compatibility for the Ditto Rust SDK, there are a few properties that we need to check in order to ensure that we can deploy a Ditto-powered app to a device. These properties are:
- The Target triple of the device where the app will be deployed,
- The Ditto SDK version the app depends on, and
- The Rust toolchain version used to compile the app
Compilers use terms known as “target triples” to describe the architecture, operating system, and additional details about a system to compile programs for. The following targets are officially supported by the Ditto Rust SDK:
Architecture | Operating System | Target Triples |
Intel Core (x86_64) | macOS (11+) | x86_64-apple-darwin |
| Linux | x86_64-unknown-linux-gnu |
ARM 64-bit (aarch64) | macOS | aarch64-apple-darwin |
| Linux | aarch64-unknown-linux-gnu |
Raspberry Pi (ARM) | Raspbian (Linux) | armv7-unknown-linux-gnueabihf |
Before getting started with development, it’s nice to check for certain that the device you’re working with actually has the target triple you think it should. Fortunately, Rust provides an easy way to check what the exact target triple for a device is. This easy method requires installing Rust on the target machine (the one where the app will be deployed), then running the command rustc -vV to check the compiler version information. For example, from an M1 Macbook Pro, we see an output like this:
Here, the field labeled "host" describes the target triple of the machine where we ran this command, in this case our target triple is aarch64-apple-darwin.
The Ditto Rust SDK is slightly different from most Rust libraries because it has strict requirements on the Rust toolchain version that must be used to compile it. We’re working to relax this requirement, but for now what you need to know is that when you import a given Ditto SDK version, you must use the exact matching Rust toolchain version as shown below:
Ditto SDK version | Rust Toolchain version |
"=4.7.x" | 1.74.1 |
"=4.6.x" | 1.74.1 |
"=4.0.x" - "=4.5.x" | 1.66.1 |
"=3.x.y" | 1.64.0 |
Here, we recommend using the "=x.y.z" notation for semantic versions of the SDK so that cargo doesn’t try to automatically upgrade your minor version. Since each version of the SDK must be matched exactly to the toolchain it was compiled with, auto-upgrades of minor versions could actually break your build. Additionally, we recommend specifying the versions of both the dittolive-ditto and dittolive-ditto-sys packages, like this:
The easiest way to choose a specific toolchain version for a project is to create a file called rust-toolchain in your project directory (next to the Cargo.toml). For example, when using the 4.7.1 SDK, set the 1.74.1 toolchain like this:
You can confirm that this works by running rustup show in your project directory, which should show details about your active toolchain, like this:
Some platforms do not support all of the types of transports that Ditto provides in general. Here is a table of which platforms support which transports, which you can use to help plan out your application.