Skip to content

Instantly share code, notes, and snippets.

@JDeeth
Created January 10, 2024 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JDeeth/2725770647cc6b24dae257c231edc45d to your computer and use it in GitHub Desktop.
Save JDeeth/2725770647cc6b24dae257c231edc45d to your computer and use it in GitHub Desktop.
X-Plane Rust minimal example
[package]
name = "hello-rust"
version = "0.1.0"
edition = "2021"
[dependencies]
xplm = { git = "https://github.com/samcrow/rust-xplm", branch = "master" }
[profile.dev]
opt-level = 2
[profile.dev.package."*"]
opt-level = 3
[lib]
crate-type = ["cdylib"]
bench = false
// src/lib.rs
extern crate xplm;
use xplm::plugin::{Plugin, PluginInfo};
use xplm::{debugln, xplane_plugin};
struct MinimalPlugin;
impl Plugin for MinimalPlugin {
type Error = std::convert::Infallible;
fn start() -> Result<Self, Self::Error> {
// The following message should be visible in the developer console and the Log.txt file
debugln!("Hello, World! From the Minimal Rust Plugin");
Ok(MinimalPlugin)
}
fn info(&self) -> PluginInfo {
PluginInfo {
name: String::from("Minimal Rust Plugin"),
signature: String::from("org.samcrow.xplm.examples.minimal"),
description: String::from("A plugin written in Rust"),
}
}
}
xplane_plugin!(MinimalPlugin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment