Skip to content

Commit e0506f0

Browse files
committed
docs
1 parent 2eb9ea5 commit e0506f0

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
[package]
22
name = "msfs"
3-
version = "0.1.0"
3+
version = "0.0.0-pre.1"
44
authors = ["snek"]
55
edition = "2018"
6+
description = "Rust bindings for the MSFS SDK"
7+
license-file = "LICENSE"
68

79
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
810

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2020 msfs-rs Contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to
5+
deal in the Software without restriction, including without limitation the
6+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
sell copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
IN THE SOFTWARE.
20+

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod sys;
44

55
// Prevent compilation of non wasm32-wasi targets
66
#[cfg(not(target_os = "wasi"))]
7+
#[doc(hidden)]
78
fn invalid() {
89
let _: [(); 0] = [0]; // This library only supports wasm32-wasi
910
}

src/msfs.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
use crate::sys;
22

3+
/// MSFS Context. Hashable.
4+
#[derive(PartialEq, Hash)]
35
pub struct FsContext(sys::FsContext);
46

7+
impl From<sys::FsContext> for FsContext {
8+
fn from(ctx: sys::FsContext) -> FsContext {
9+
FsContext(ctx)
10+
}
11+
}
12+
13+
/// `PanelServiceID` is used in `GaugeCallback`s and is generated from
14+
/// `sys::PANEL_SERVICE_*` constants.
515
#[repr(u32)]
16+
#[derive(PartialEq, Clone, Copy)]
617
pub enum PanelServiceID {
718
PreQuery = sys::PANEL_SERVICE_PRE_QUERY,
819
PostQuery = sys::PANEL_SERVICE_POST_QUERY,
@@ -24,15 +35,18 @@ pub enum PanelServiceID {
2435
PanelClose = sys::PANEL_SERVICE_PANEL_CLOSE,
2536
}
2637

27-
impl From<sys::FsContext> for FsContext {
28-
fn from(ctx: sys::FsContext) -> FsContext {
29-
FsContext(ctx)
30-
}
31-
}
32-
33-
pub type GuageCallbackResult = Result<(), ()>;
38+
/// MSFS Gauges are managed using this lifecycle callback.
3439
pub type GaugeCallback = fn(&FsContext, PanelServiceID) -> GuageCallbackResult;
40+
pub type GuageCallbackResult = Result<(), ()>;
3541

42+
/// `gauge!` is used to generate the exported function which is exposed to
43+
/// MSFS when it loads the WASM binary. Use it like so:
44+
/// ```rs
45+
/// fn my_gauge(ctx: &FsContext, servce_id: PanelServiceID) -> GaugeResult {
46+
/// Ok(())
47+
/// }
48+
/// gauge!(my_gauge);
49+
/// ```
3650
// FIXME: this should be a proc macro like:
3751
// ```rs
3852
// #[msfs::gauge]

0 commit comments

Comments
 (0)