Created
January 10, 2024 22:10
-
-
Save JDeeth/2725770647cc6b24dae257c231edc45d to your computer and use it in GitHub Desktop.
X-Plane Rust minimal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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