pub struct PermissionsContainer { /* private fields */ }
Expand description
Wrapper struct for Permissions
that can be shared across threads.
We need a way to have internal mutability for permissions as they might get passed to a future that will prompt the user for permission (and in such case might need to be mutated). Also for the Web Worker API we need a way to send permissions to a new thread.
Implementations§
Source§impl PermissionsContainer
impl PermissionsContainer
pub fn new( descriptor_parser: Arc<dyn PermissionDescriptorParser>, perms: Permissions, ) -> Self
pub fn allow_all(descriptor_parser: Arc<dyn PermissionDescriptorParser>) -> Self
pub fn create_child_permissions( &self, child_permissions_arg: ChildPermissionsArg, ) -> Result<PermissionsContainer, ChildPermissionError>
pub fn check_specifier( &self, specifier: &ModuleSpecifier, kind: CheckSpecifierKind, ) -> Result<(), PermissionCheckError>
pub fn check_read( &self, path: &str, api_name: &str, ) -> Result<PathBuf, PermissionCheckError>
pub fn check_read_with_api_name( &self, path: &str, api_name: Option<&str>, ) -> Result<PathBuf, PermissionCheckError>
pub fn check_read_path<'a>( &self, path: &'a Path, api_name: Option<&str>, ) -> Result<Cow<'a, Path>, PermissionCheckError>
Sourcepub fn check_read_blind(
&mut self,
path: &Path,
display: &str,
api_name: &str,
) -> Result<(), PermissionCheckError>
pub fn check_read_blind( &mut self, path: &Path, display: &str, api_name: &str, ) -> Result<(), PermissionCheckError>
As check_read()
, but permission error messages will anonymize the path
by replacing it with the given display
.
pub fn check_read_all(&self, api_name: &str) -> Result<(), PermissionCheckError>
pub fn query_read_all(&self) -> bool
pub fn check_write( &self, path: &str, api_name: &str, ) -> Result<PathBuf, PermissionCheckError>
pub fn check_write_with_api_name( &self, path: &str, api_name: Option<&str>, ) -> Result<PathBuf, PermissionCheckError>
pub fn check_write_path<'a>( &self, path: &'a Path, api_name: &str, ) -> Result<Cow<'a, Path>, PermissionCheckError>
pub fn check_write_all( &self, api_name: &str, ) -> Result<(), PermissionCheckError>
Sourcepub fn check_write_blind(
&self,
path: &Path,
display: &str,
api_name: &str,
) -> Result<(), PermissionCheckError>
pub fn check_write_blind( &self, path: &Path, display: &str, api_name: &str, ) -> Result<(), PermissionCheckError>
As check_write()
, but permission error messages will anonymize the path
by replacing it with the given display
.
pub fn check_write_partial( &mut self, path: &str, api_name: &str, ) -> Result<PathBuf, PermissionCheckError>
pub fn check_run( &mut self, cmd: &RunQueryDescriptor, api_name: &str, ) -> Result<(), PermissionCheckError>
pub fn check_run_all( &mut self, api_name: &str, ) -> Result<(), PermissionCheckError>
pub fn query_run_all(&mut self, api_name: &str) -> bool
pub fn check_sys( &self, kind: &str, api_name: &str, ) -> Result<(), PermissionCheckError>
pub fn check_env(&mut self, var: &str) -> Result<(), PermissionCheckError>
pub fn check_env_all(&mut self) -> Result<(), PermissionCheckError>
pub fn check_sys_all(&mut self) -> Result<(), PermissionCheckError>
pub fn check_ffi_all(&mut self) -> Result<(), PermissionCheckError>
Sourcepub fn check_was_allow_all_flag_passed(
&mut self,
) -> Result<(), PermissionCheckError>
pub fn check_was_allow_all_flag_passed( &mut self, ) -> Result<(), PermissionCheckError>
This checks to see if the allow-all flag was passed, not whether all permissions are enabled!
Sourcepub fn check_special_file(
&mut self,
path: &Path,
_api_name: &str,
) -> Result<(), &'static str>
pub fn check_special_file( &mut self, path: &Path, _api_name: &str, ) -> Result<(), &'static str>
Checks special file access, returning the failed permission type if not successful.
pub fn check_net_url( &mut self, url: &Url, api_name: &str, ) -> Result<(), PermissionCheckError>
pub fn check_net<T: AsRef<str>>( &mut self, host: &(T, Option<u16>), api_name: &str, ) -> Result<(), PermissionCheckError>
pub fn check_ffi(&mut self, path: &str) -> Result<PathBuf, PermissionCheckError>
pub fn check_ffi_partial_no_path(&mut self) -> Result<(), PermissionCheckError>
pub fn check_ffi_partial_with_path( &mut self, path: &str, ) -> Result<PathBuf, PermissionCheckError>
pub fn query_read( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn query_write( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn query_net( &self, host: Option<&str>, ) -> Result<PermissionState, NetDescriptorParseError>
pub fn query_env(&self, var: Option<&str>) -> PermissionState
pub fn query_sys( &self, kind: Option<&str>, ) -> Result<PermissionState, SysDescriptorParseError>
pub fn query_run( &self, cmd: Option<&str>, ) -> Result<PermissionState, RunDescriptorParseError>
pub fn query_ffi( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn revoke_read( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn revoke_write( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn revoke_net( &self, host: Option<&str>, ) -> Result<PermissionState, NetDescriptorParseError>
pub fn revoke_env(&self, var: Option<&str>) -> PermissionState
pub fn revoke_sys( &self, kind: Option<&str>, ) -> Result<PermissionState, SysDescriptorParseError>
pub fn revoke_run( &self, cmd: Option<&str>, ) -> Result<PermissionState, RunDescriptorParseError>
pub fn revoke_ffi( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn request_read( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn request_write( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
pub fn request_net( &self, host: Option<&str>, ) -> Result<PermissionState, NetDescriptorParseError>
pub fn request_env(&self, var: Option<&str>) -> PermissionState
pub fn request_sys( &self, kind: Option<&str>, ) -> Result<PermissionState, SysDescriptorParseError>
pub fn request_run( &self, cmd: Option<&str>, ) -> Result<PermissionState, RunDescriptorParseError>
pub fn request_ffi( &self, path: Option<&str>, ) -> Result<PermissionState, PathResolveError>
Trait Implementations§
Source§impl Clone for PermissionsContainer
impl Clone for PermissionsContainer
Source§fn clone(&self) -> PermissionsContainer
fn clone(&self) -> PermissionsContainer
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PermissionsContainer
impl !RefUnwindSafe for PermissionsContainer
impl Send for PermissionsContainer
impl Sync for PermissionsContainer
impl Unpin for PermissionsContainer
impl !UnwindSafe for PermissionsContainer
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.