Struct deno_runtime::permissions::PermissionsContainer
source · pub struct PermissionsContainer(pub Arc<Mutex<Permissions>>);
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.
Tuple Fields§
§0: Arc<Mutex<Permissions>>
Implementations§
source§impl PermissionsContainer
impl PermissionsContainer
pub fn new(perms: Permissions) -> Self
sourcepub fn allow_all() -> Self
pub fn allow_all() -> Self
Examples found in repository?
examples/extension_with_ops/main.rs (line 28)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
async fn main() -> Result<(), AnyError> {
let js_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("examples/extension_with_ops/main.js");
let main_module = ModuleSpecifier::from_file_path(js_path).unwrap();
let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::allow_all(),
WorkerOptions {
module_loader: Rc::new(FsModuleLoader),
extensions: vec![hello_runtime::init_ops()],
..Default::default()
},
);
worker.execute_main_module(&main_module).await?;
worker.run_event_loop(false).await?;
Ok(())
}
More examples
examples/extension_with_esm/main.rs (line 26)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
async fn main() -> Result<(), AnyError> {
let js_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("examples/extension_with_esm/main.js");
let main_module = ModuleSpecifier::from_file_path(js_path).unwrap();
let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::allow_all(),
WorkerOptions {
module_loader: Rc::new(FsModuleLoader),
extensions: vec![hello_runtime::init_ops_and_esm()],
..Default::default()
},
);
worker.execute_main_module(&main_module).await?;
worker.run_event_loop(false).await?;
Ok(())
}
pub fn check_specifier( &self, specifier: &ModuleSpecifier ) -> Result<(), AnyError>
pub fn check_read( &mut self, path: &Path, api_name: &str ) -> Result<(), AnyError>
pub fn check_read_blind( &mut self, path: &Path, display: &str, api_name: &str ) -> Result<(), AnyError>
pub fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError>
pub fn check_write( &mut self, path: &Path, api_name: &str ) -> Result<(), AnyError>
pub fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError>
pub fn check_write_blind( &mut self, path: &Path, display: &str, api_name: &str ) -> Result<(), AnyError>
pub fn check_run(&mut self, cmd: &str, api_name: &str) -> Result<(), AnyError>
pub fn check_run_all(&mut self, api_name: &str) -> Result<(), AnyError>
pub fn check_sys(&mut self, kind: &str, api_name: &str) -> Result<(), AnyError>
pub fn check_env(&mut self, var: &str) -> Result<(), AnyError>
pub fn check_env_all(&mut self) -> Result<(), AnyError>
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 moresource§impl Debug for PermissionsContainer
impl Debug for PermissionsContainer
source§impl FsPermissions for PermissionsContainer
impl FsPermissions for PermissionsContainer
fn check_read(&mut self, path: &Path, api_name: &str) -> Result<(), AnyError>
fn check_read_blind( &mut self, path: &Path, display: &str, api_name: &str ) -> Result<(), AnyError>
fn check_write(&mut self, path: &Path, api_name: &str) -> Result<(), AnyError>
fn check_write_partial( &mut self, path: &Path, api_name: &str ) -> Result<(), AnyError>
fn check_write_blind( &mut self, p: &Path, display: &str, api_name: &str ) -> Result<(), AnyError>
fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError>
fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError>
fn check( &mut self, open_options: &OpenOptions, path: &Path, api_name: &str ) -> Result<(), Error>
source§impl TimersPermission for PermissionsContainer
impl TimersPermission for PermissionsContainer
fn allow_hrtime(&mut self) -> bool
Auto Trait Implementations§
impl Send for PermissionsContainer
impl Sync for PermissionsContainer
impl !RefUnwindSafe for PermissionsContainer
impl Unpin for PermissionsContainer
impl !UnwindSafe for PermissionsContainer
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,
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