/rust-xplm

Rust interfaces to the X-Plane plugin SDK

Primary LanguageRustApache License 2.0Apache-2.0

X-Plane plugin APIs for Rust

Crates.io Version Documentation License

Purpose

Rust XPLM provides a convenient interface for X-Plane plugin development in the Rust programming language for all platforms.

As we use the X-Plane SDK version 3.0, any plugin created with this library supports X-Plane version 11.10 or later.

Status

The library is still in an incomplete state. As a result some parts of the SDK may only be sparsely covered or missing completely.

  • Compiles and is callable from X-Plane
  • Debug logging to the console / log file
  • DataRef reading and writing
  • Commands
  • GUI - Needs further work
  • Drawing - Needs further work

Example

Some more examples can be found in the examples/ directory.

This small snipped, however, is the minimal boilerplate needed to make your plugin compile.

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);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.