33 releases (7 breaking)

0.8.1 Mar 16, 2024
0.7.0 Feb 4, 2024
0.6.7 Oct 18, 2023
0.4.0 Mar 24, 2023
0.1.0 Sep 14, 2020

#48 in GUI

Download history 4892/week @ 2023-12-07 4994/week @ 2023-12-14 4847/week @ 2023-12-21 4359/week @ 2023-12-28 5924/week @ 2024-01-04 5721/week @ 2024-01-11 5484/week @ 2024-01-18 6032/week @ 2024-01-25 5684/week @ 2024-02-01 6568/week @ 2024-02-08 11570/week @ 2024-02-15 13474/week @ 2024-02-22 15140/week @ 2024-02-29 15785/week @ 2024-03-07 17946/week @ 2024-03-14 13896/week @ 2024-03-21

64,820 downloads per month
Used in 69 crates (8 directly)

MIT license

390KB
7K SLoC

ASHPD

docs crates.io CI

ASHPD, acronym of Aperture Science Handheld Portal Device is a Rust & zbus wrapper of the XDG portals DBus interfaces. The library aims to provide an easy way to interact with the various portals defined per the specifications. It provides an alternative to the C library https://github.com/flatpak/libportal

Examples

Ask the compositor to pick a color

use ashpd::desktop::Color;

async fn run() -> ashpd::Result<()> {
    let color = Color::pick().send().await?.response()?;
    println!("({}, {}, {})", color.red(), color.green(), color.blue());
    Ok(())
}

Start a PipeWire stream from the user's camera

use ashpd::desktop::camera::Camera;

pub async fn run() -> ashpd::Result<()> {
    let camera = Camera::new().await?;
    if camera.is_present().await? {
        camera.request_access().await?;
        let remote_fd = camera.open_pipe_wire_remote().await?;
        // pass the remote fd to GStreamer for example
    }
    Ok(())
}

Optional features

Feature Description Default
tracing Record various debug information using the tracing library No
tokio Enable tokio runtime on zbus dependency No
async-std Enable the use of the async-std runtime Yes
glib Make all the enums derive glib::Enum. Flags are not supported yet No
gtk4 Implement From<Color> for gdk4::RGBA Provides WindowIdentifier::from_native that takes a IsA<gtk4::Native> No
gtk4_wayland Provides WindowIdentifier::from_native that takes a IsA<gtk4::Native> with Wayland backend support only No
gtk4_x11 Provides WindowIdentifier::from_native that takes a IsA<gtk4::Native> with X11 backend support only No
pipewire Provides ashpd::desktop::camera::pipewire_streams that helps you retrieve the various camera streams associated with the retrieved file descriptor No
raw_handle Provides WindowIdentifier::from_raw_handle and WindowIdentifier::as_raw_handle for raw-window-handle crate No
wayland Provides WindowIdentifier::from_wayland for wayland-client crate No

Demo

The library comes with a demo built using the GTK 4 Rust bindings and previews most of the portals. It is meant as a test case for the portals (from a distributor perspective) and as a way for the developers to see which portals exists and how to integrate them into their application using ASHPD.

Dependencies

~10–26MB
~411K SLoC