#[non_exhaustive]pub struct Capabilities {
pub process: ProcessGrants,
pub fs: FileGrants,
pub network: NetworkGrants,
pub webview: Option<Vec<HostPattern>>,
pub status_bar: bool,
pub clipboard: bool,
pub picker: bool,
pub host: Vec<String>,
pub open_url: Option<OpenUrlGrant>,
}Expand description
What an app may do (one declaration, or one grant).
Start with Self::default and set the fields to grant; new capabilities
default to denied.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.process: ProcessGrantsExplicit native subprocess grants.
fs: FileGrantsExplicit native filesystem grants.
network: NetworkGrantsfetch, remote images and video.
webview: Option<Vec<HostPattern>>The hosts web views may show; None: no web views.
status_bar: boolThe app may set the status bar.
clipboard: boolThe app may read and write the system clipboard (nsh/clipboard).
picker: boolThe app may show the system’s picker (nsh/picker): the files the
user picks in it reach the app.
host: Vec<String>The functions of the embedding app nsh/host may call: names, or
prefixes ending in * ("*": all); empty: none, also for apps
without a declaration (Capabilities::all).
open_url: Option<OpenUrlGrant>The URLs the app may open outside it (openUrl of nsh/device);
None: none.
Implementations§
Source§impl Capabilities
impl Capabilities
Sourcepub fn all() -> Capabilities
pub fn all() -> Capabilities
Legacy unrestricted APIs for apps without a declaration. Socket, process, filesystem and host function grants stay empty and always require explicit opt-in.
Sourcepub fn from_json(value: &Value) -> Result<Capabilities, String>
pub fn from_json(value: &Value) -> Result<Capabilities, String>
Parses capabilities from nsh.json (or a grant in the same form).
Unknown keys are errors: a typo is caught when the app is built.
Sourcepub fn from_json_lenient(
value: &Value,
) -> Result<(Capabilities, Vec<String>), String>
pub fn from_json_lenient( value: &Value, ) -> Result<(Capabilities, Vec<String>), String>
Parses the capabilities a signed package declares, which a newer
signer may have written: unknown keys never grant anything. An
unknown capability is not granted; an unknown key inside one (a
restriction this runtime cannot apply) drops what it is in, the
whole capability or the http grant. Returns what was dropped
(capabilities.bluetooth, …) with the capabilities.
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
The JSON form Capabilities::from_json reads.
Trait Implementations§
Source§impl Clone for Capabilities
impl Clone for Capabilities
Source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Capabilities
impl Debug for Capabilities
Source§impl Default for Capabilities
impl Default for Capabilities
Source§fn default() -> Capabilities
fn default() -> Capabilities
impl Eq for Capabilities
Source§impl PartialEq for Capabilities
impl PartialEq for Capabilities
impl StructuralPartialEq for Capabilities
Auto Trait Implementations§
impl Freeze for Capabilities
impl RefUnwindSafe for Capabilities
impl Send for Capabilities
impl Sync for Capabilities
impl Unpin for Capabilities
impl UnsafeUnpin for Capabilities
impl UnwindSafe for Capabilities
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.