pub struct Access {
pub declared: Capabilities,
pub granted: Option<Capabilities>,
}Expand description
What an app may do: its declaration and the embedder’s grant (when the embedder limits it); an action must be allowed by both.
Fields§
§declared: CapabilitiesWhat the app declared (everything without a declaration).
granted: Option<Capabilities>What the embedding app grants it at most (None: what it declared).
Implementations§
Source§impl Access
impl Access
Sourcepub fn is_unrestricted(&self) -> bool
pub fn is_unrestricted(&self) -> bool
True when nothing is restricted (no check needed, redirects may be followed by the platform).
Sourcepub fn allows_process(&self, command: &str) -> bool
pub fn allows_process(&self, command: &str) -> bool
Whether an exact command is declared and granted. These capabilities always require explicit opt-in, including for legacy standalone apps.
Sourcepub fn allows_exit(&self) -> bool
pub fn allows_exit(&self) -> bool
Whether the app may request an exit from its host. This never exits the embedding process by itself; the host supplies the meaning of the request.
Sourcepub fn allows_env(&self, name: &str) -> bool
pub fn allows_env(&self, name: &str) -> bool
Whether an environment variable is visible. The built-in metadata names are always visible; other names require both app and host permission.
Resolve a filesystem path within both the declaration and host grant.
data_dir is an app-specific directory supplied only by the host.
Authorize a file with trusted host source and home directory anchors.
Sourcepub fn allows_socket(&self, host: &str, port: u16) -> bool
pub fn allows_socket(&self, host: &str, port: u16) -> bool
Whether a raw TCP connection to host:port may be opened: only an
exact network.sockets grant allows it, never hosts or http
grants, and Capabilities::all grants none.
Sourcepub fn allows_websocket(&self, url: &str) -> bool
pub fn allows_websocket(&self, url: &str) -> bool
Whether a WebSocket to url (ws: / wss:) may connect. The
handshake is an HTTP GET, so it is checked as a GET of the same URL
over http: / https:; legacy rules may also list ws / wss.
Sourcepub fn allows_http(&self, method: &str, url: &str) -> bool
pub fn allows_http(&self, method: &str, url: &str) -> bool
Whether fetch(url, { method }) may go out. asset: URIs are always
allowed.
Sourcepub fn http_url<'a>(&self, method: &str, url: &'a str) -> Option<Cow<'a, str>>
pub fn http_url<'a>(&self, method: &str, url: &'a str) -> Option<Cow<'a, str>>
The URL a request to url goes out with, if the app may make it:
its WHATWG serialization, which Self::allows_http checks, so the
loader requests what was granted. asset: URIs stay as written.
Sourcepub fn allows_media(&self, uri: &str) -> bool
pub fn allows_media(&self, uri: &str) -> bool
Whether a media URL (image, video, canvas image) may be loaded:
Self::media_url with no base, so a // source names no URL, and
no file roots, so an app with capabilities loads no local file.
Sourcepub fn media_url<'a>(
&self,
uri: &'a str,
base: Option<&str>,
files: Option<&MediaFiles>,
) -> Option<Cow<'a, str>>
pub fn media_url<'a>( &self, uri: &'a str, base: Option<&str>, files: Option<&MediaFiles>, ) -> Option<Cow<'a, str>>
What a media source (image, video, canvas image, sound) loads, if the
app may load it. asset: URIs are the app’s own files; data: URIs
and blob: URLs (URL.createObjectURL) are bytes the app already
has: these stay as written. A source with no scheme that does not
start with / or a backslash is relative: the page’s with a base,
and with none (a native app, whose players read it against the
working directory) it loads nothing. A local
file (a file: URL; with no base, as in native apps, an absolute
path; on the web /… is the page’s) is read under files, the
capabilities.fs.read roots (MediaFiles; None: none), and
loads as its canonical path, in the form it was written. A source with a
scheme, or one that starts with // (resolved against base, the
page’s URL on the web, whose scheme it takes; with no base it names
no URL, as fetch’s), names a host: it is checked as WHATWG’s parser
reads it and loads as its serialization, so the loader loads what
was granted. A backslash before the query or a control character is
read differently by other parsers (Foundation’s NSURL): only a
grant of every host covers such a source, as written. An app without
capabilities loads what it writes, unchecked.
Sourcepub fn media_redirect(
&self,
base: &str,
location: &str,
) -> Result<String, String>
pub fn media_redirect( &self, base: &str, location: &str, ) -> Result<String, String>
The next URL of a media load that was redirected from base to
location, if the app may load it: the redirect must stay on
http(s) and pass the same check as a first request, so loaders
follow redirects themselves, one hop at a time, and never contact
a target the app is not granted.
Sourcepub fn allows_webviews(&self) -> bool
pub fn allows_webviews(&self) -> bool
Whether web views are granted at all (inline HTML needs only this).
Sourcepub fn allows_webview(&self, url: &str) -> bool
pub fn allows_webview(&self, url: &str) -> bool
Whether a web view may show (or navigate to) url; about:blank
whenever web views are granted.
Sourcepub fn allows_web_input(&self) -> bool
pub fn allows_web_input(&self) -> bool
Whether a web view’s ref may give its page trusted input
(sendInput): declared and granted, never by default.
Sourcepub fn allows_web_media(&self, media: WebMedia) -> bool
pub fn allows_web_media(&self, media: WebMedia) -> bool
Whether a web view’s page may capture media (getUserMedia):
declared and granted, never by default. The system still asks the
user.
Sourcepub fn check_window(
&self,
kind: WindowKind,
attributes: &WindowAttributes,
open: usize,
) -> Result<(), String>
pub fn check_window( &self, kind: WindowKind, attributes: &WindowAttributes, open: usize, ) -> Result<(), String>
Whether the app may open a window of kind with attributes (its
own, before its kind’s defaults) while open windows besides the
main one are open; the message of the refusal otherwise (the call
fails with ERR_ACCESS_DENIED, permission windows).
Sourcepub fn deny_window_attributes(
&self,
attributes: &mut WindowAttributes,
) -> Vec<&'static str>
pub fn deny_window_attributes( &self, attributes: &mut WindowAttributes, ) -> Vec<&'static str>
Leaves out of attributes what the app’s capabilities do not grant
a window (an ungranted level, click-through without overlay) and
returns their
names, for a warning. The main window needs no windows grant for
the rest.
Sourcepub fn allows_status_bar(&self) -> bool
pub fn allows_status_bar(&self) -> bool
Whether the app may set the status bar.
Sourcepub fn allows_clipboard(&self) -> bool
pub fn allows_clipboard(&self) -> bool
Whether the app may read and write the system clipboard.
Sourcepub fn allows_picker(&self) -> bool
pub fn allows_picker(&self) -> bool
Whether the app may show the system’s picker (nsh/picker).
Sourcepub fn allows_speech(&self) -> bool
pub fn allows_speech(&self) -> bool
Whether the app may recognize the user’s speech (Speech of nsh).
Sourcepub fn allows_notifications(&self) -> bool
pub fn allows_notifications(&self) -> bool
Whether the app may show notifications and set its badge
(Notifications of nsh).
Sourcepub fn allows_audio(&self) -> bool
pub fn allows_audio(&self) -> bool
Whether the app may play sound (Sound and AudioPlayer of nsh).
Sourcepub fn allows_host(&self, name: &str) -> bool
pub fn allows_host(&self, name: &str) -> bool
Whether nsh/host may call the embedding app’s function name.
Sourcepub fn allows_open_url(&self, url: &str) -> bool
pub fn allows_open_url(&self, url: &str) -> bool
Whether the app may open url outside it (openUrl of
nsh/device): its scheme is granted.
Trait Implementations§
impl Eq for Access
impl StructuralPartialEq for Access
Auto Trait Implementations§
impl Forget for Access
impl Freeze for Access
impl Move for Access
impl RefUnwindSafe for Access
impl Send for Access
impl Sync for Access
impl Unpin for Access
impl UnsafeUnpin for Access
impl UnwindSafe for Access
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.