async fn new_flightgear_stream(
    base_uri: &str,
) -> Result<impl Stream<Item = Result<PropertyTreeLeaf, Box<dyn Error>>>, Box<dyn Error>> {
    let url = format!("ws://{}/PropertyListener", base_uri);
    let (mut stream, _) = async_tungstenite::async_std::connect_async(url).await?;

    for node in KEYS {
        let sub = FlightgearCommand {
            command: "addListener".to_string(),
            node: node.to_string(),
        };
        stream
            .send(Message::Binary(serde_json::to_vec(&sub)?))
            .await?;
    }

    Ok(stream
        .map(|msg| -> Result<_, Box<dyn Error>> { Ok(serde_json::from_slice(&msg?.into_data())?) }))
}
/// Yields AircraftStates from a Flightgear http/json connection
///
/// # Arguments
/// `base_uri` - The base URI of the Flightgear http interface. Something like `localhost:5400`.
Yields AircraftStates from a Flightgear http/json connection
Yields AircraftStates from a Flightgear http / json connection
async fn new_flightgear_stream(
    base_uri: &str,
) -> Result<impl Stream<Item = Result<PropertyTreeLeaf, Box<dyn Error>>>, Box<dyn Error>> {
    let url = format!("ws://{}/PropertyListener", base_uri);
    let (mut stream, _) = async_tungstenite::async_std::connect_async(url).await?;
    for node in KEYS {
        let sub = FlightgearCommand {
            command: "addListener".to_string(),
            node: node.to_string(),
        };
        stream
            .send(Message::Binary(serde_json::to_vec(&sub)?))
            .await?;
    }
    Ok(stream
        .map(|msg| -> Result<_, Box<dyn Error>> { Ok(serde_json::from_slice(&msg?.into_data())?) }))
}
async fn new_flightgear_stream ( base_uri : & str , ) -> Result < impl Stream < Item = Result < PropertyTreeLeaf , Box < dyn Error > > > , Box < dyn Error > > { let url = format ! ( " " base_uri ) ; let ( mut stream , _ ) = async_tungstenite :: async_std :: connect_async ( url ) . await ? ; for node in KEYS { let sub = FlightgearCommand { command : " " . to_string ( ) , node : node . to_string ( ) , } ; stream . send ( Message :: Binary ( serde_json :: to_vec ( & sub ) ? ) ) . await ? ; } Ok ( stream . map ( | msg | -> Result < _ , Box < dyn Error > > { Ok ( serde_json :: from_slice ( & msg ? . into_data ( ) ) ? ) } ) ) }
Yields AircraftStates from a Flightgear http/json connection
Yields AircraftStates from a Flightgear http / json connection
base_uri
&str
base_uri
&str