Skip to main content

Module open_uri

Module open_uri 

Source
Available on crate feature open_uri only.
Expand description

Open a URI or a directory.

Wrapper of the DBus interface: org.freedesktop.portal.OpenURI.

§Examples

§Open a file

use std::{fs::File, os::fd::AsFd};

use ashpd::desktop::open_uri::OpenFileRequest;

async fn run() -> ashpd::Result<()> {
    let file = File::open("/home/bilelmoussaoui/adwaita-day.jpg").unwrap();
    OpenFileRequest::default()
        .ask(true)
        .send_file(&file.as_fd())
        .await?;
    Ok(())
}

§Open a file from a URI

use ashpd::desktop::open_uri::OpenFileRequest;

async fn run() -> ashpd::Result<()> {
    let uri =
        ashpd::Uri::parse("file:///home/bilelmoussaoui/Downloads/adwaita-night.jpg").unwrap();
    OpenFileRequest::default().ask(true).send_uri(&uri).await?;
    Ok(())
}

§Open a directory

use std::{fs::File, os::fd::AsFd};

use ashpd::desktop::open_uri::OpenDirectoryRequest;

async fn run() -> ashpd::Result<()> {
    let directory = File::open("/home/bilelmoussaoui/Downloads").unwrap();
    OpenDirectoryRequest::default()
        .send(&directory.as_fd())
        .await?;
    Ok(())
}

Structs§

OpenDirOptions
Options passed to OpenURIProxy::open_directory.
OpenDirectoryRequest
A builder-pattern type to open a directory.
OpenFileOptions
Options passed to OpenURIProxy::open_file.
OpenFileRequest
A builder-pattern type to open a file.
OpenURIProxy
The interface lets sandboxed applications open URIs (e.g. a http: link to the applications homepage) under the control of the user.
SchemeSupportedOptions
Options passed to OpenURIProxy::scheme_supported.