1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![deny(rustdoc::broken_intra_doc_links)]
3#![deny(missing_docs)]
4#![doc(
5 html_logo_url = "https://raw.githubusercontent.com/bilelmoussaoui/ashpd/master/ashpd-demo/data/icons/com.belmoussaoui.ashpd.demo.svg",
6 html_favicon_url = "https://raw.githubusercontent.com/bilelmoussaoui/ashpd/master/ashpd-demo/data/icons/com.belmoussaoui.ashpd.demo-symbolic.svg"
7)]
8#![doc = include_str!("../README.md")]
9#[cfg(all(all(feature = "tokio", feature = "async-std"), not(doc)))]
10compile_error!("You can't enable both async-std & tokio features at once");
11#[cfg(all(not(feature = "tokio"), not(feature = "async-std"), not(doc)))]
12compile_error!("Either the `async-std` or the `tokio` feature has to be enabled");
13
14pub type Result<T> = std::result::Result<T, Error>;
16
17static IS_SANDBOXED: OnceLock<bool> = OnceLock::new();
18
19mod activation_token;
20pub mod desktop;
23pub mod documents;
25mod error;
26mod window_identifier;
27
28pub use self::{activation_token::ActivationToken, window_identifier::WindowIdentifier};
29mod app_id;
30mod registry;
31pub use self::{app_id::AppID, registry::register_host_app};
32mod file_path;
33pub use self::file_path::FilePath;
34
35mod proxy;
36
37#[cfg(feature = "backend")]
38#[cfg_attr(docsrs, doc(cfg(feature = "backend")))]
39pub use self::window_identifier::WindowIdentifierType;
40#[cfg(feature = "backend")]
41#[cfg_attr(docsrs, doc(cfg(feature = "backend")))]
42#[allow(missing_docs)]
43pub mod backend;
45pub mod flatpak;
48mod helpers;
49use std::sync::OnceLock;
50
51#[cfg(feature = "backend")]
52#[cfg_attr(docsrs, doc(cfg(feature = "backend")))]
53pub use async_trait;
54pub use enumflags2;
55pub use url;
56pub use zbus::{self, zvariant};
57
58pub async fn is_sandboxed() -> bool {
65 if let Some(cached_value) = IS_SANDBOXED.get() {
66 return *cached_value;
67 }
68 let new_value = crate::helpers::is_flatpak().await
69 || crate::helpers::is_snap().await
70 || std::env::var("GTK_USE_PORTAL")
71 .map(|v| v == "1")
72 .unwrap_or(false);
73
74 *IS_SANDBOXED.get_or_init(|| new_value)
75}
76
77pub use self::error::{Error, PortalError};
78
79mod sealed {
80 pub trait Sealed {}
83}
84
85pub(crate) use sealed::Sealed;
86
87pub type Pid = u32;