Attribute Macro msfs_derive::gauge

source ·
#[gauge]
Expand description

Declare a gauge callback. It will be automatically exported with the name NAME_gauge_callback, where NAME is the name of the decorated function.

use futures::stream::{Stream, StreamExt};
// Declare and export `FOO_gauge_callback`
#[msfs::gauge]
async fn FOO(mut gauge: msfs::Gauge) -> Result<(), Box<dyn std::error::Error>> {
  while let Some(event) = gauge.next_event().await {
    // ...
  }
}

The macro can also be given a parameter, name, to rename the exported function.

// Declare and export `FOO_gauge_callback`
#[msfs::gauge(name=FOO)]
async fn xyz(...) {}