1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::os::raw::c_void;
/// Accessing and communicating with other plugins
pub mod management;
/// Inter-plugin messaging
pub mod messages;
/// Items used by the xplane_plugin! macro, which must be public
#[doc(hidden)]
pub mod internal;
/// Information about a plugin
pub struct PluginInfo {
/// The plugin name
pub name: String,
/// The plugin's signature, in reverse DNS format
pub signature: String,
/// A description of the plugin
pub description: String,
}
/// The trait that all plugins should implement
pub trait Plugin: Sized {
/// The error type that a plugin may encounter when starting up or enabling
type Error: std::error::Error;
/// Called when X-Plane loads this plugin
///
/// On success, returns a plugin object
fn start() -> Result<Self, Self::Error>;
/// Called when the plugin is enabled
///
/// If this function returns an Err, the plugin will remain disabled.
///
/// The default implementation returns Ok(()).
fn enable(&mut self) -> Result<(), Self::Error> {
Ok(())
}
/// Called when the plugin is disabled
///
/// The default implementation does nothing.
fn disable(&mut self) {}
/// Returns information on this plugin
fn info(&self) -> PluginInfo;
#[allow(unused_variables)]
/// Called when the plugin receives a message
///
/// The default implementation does nothing.
fn receive_message(&mut self, from: i32, message: i32, param: *mut c_void) {}
}