[][src]Crate ashpd

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.

use ashpd::desktop::screenshot::{Color, PickColorOptions, ScreenshotProxy};
use ashpd::{RequestProxy, Response, WindowIdentifier};
use zbus::fdo::Result;

fn main() -> Result<()> {
   let connection = zbus::Connection::new_session()?;
   let proxy = ScreenshotProxy::new(&connection)?;

   let request_handle = proxy.pick_color(
            WindowIdentifier::default(),
            PickColorOptions::default()
   )?;

   let request = RequestProxy::new(&connection, &request_handle)?;

    request.on_response(|response: Response<Color>| {
        if let Ok(color) = response {
            println!("({}, {}, {})", color.red(), color.green(), color.blue());
        }
   })?;

   Ok(())
}

Optional features

FeatureDescription
gdk_colorImplement Into<gdk::RGBA> for Color

Re-exports

pub use zbus;
pub use zvariant;

Modules

desktop

Interact with the user's desktop such as taking a screenshot, setting a background or querying the user's location.

documents

Interact with the documents store or transfer files across apps.

flatpak

Spawn commands outside the sandbox or monitor if the running application has received an update & install it.

Structs

BasicResponse

The most basic response. Used when only the status of the request is what we receive as a response.

HandleToken

A handle token is a DBus Object Path element, specified in the RequestProxy or SessionProxy object path following this format /org/freedesktop/portal/desktop/request/SENDER/TOKEN where sender is the caller's unique name and token is the HandleToken.

NString

A Null terminated string.

RequestProxy

The Request interface is shared by all portal interfaces. When a portal method is called, the reply includes a handle (i.e. object path) for a Request object, which will stay alive for the duration of the user interaction related to the method call.

SessionProxy

The Session interface is shared by all portal interfaces that involve long lived sessions. When a method that creates a session is called, if successful, the reply will include a session handle (i.e. object path) for a Session object, which will stay alive for the duration of the session.

WindowIdentifier

Most portals interact with the user by showing dialogs. These dialogs should generally be placed on top of the application window that triggered them. To arrange this, the compositor needs to know about the application window. Many portal requests expect a WindowIdentifier for this reason.

Enums

ResponseError

An error returned a portal request caused by either the user cancelling the request or something else.

Type Definitions

Response

A typical response returned by the on_response signal of a RequestProxy.