ashpd::desktop

Module location

Source
Expand description

Query the user’s GPS location.

§Examples

use ashpd::desktop::location::{Accuracy, LocationProxy};
use futures_util::{FutureExt, StreamExt};

async fn run() -> ashpd::Result<()> {
    let proxy = LocationProxy::new().await?;
    let session = proxy
        .create_session(None, None, Some(Accuracy::Street))
        .await?;
    let mut stream = proxy.receive_location_updated().await?;
    let (_, location) = futures_util::join!(
        proxy
            .start(&session, None)
            .map(|e| e.expect("Couldn't start session")),
        stream.next().map(|e| e.expect("Stream is exhausted"))
    );
    println!("{}", location.accuracy());
    println!("{}", location.longitude());
    println!("{}", location.latitude());
    session.close().await?;
    Ok(())
}

Structs§

  • The response received on a location_updated signal.
  • The interface lets sandboxed applications query basic information about the location.

Enums§