pub trait WebPermissions:
Debug
+ Send
+ Sync {
Show 14 methods
// Required methods
fn allow_hrtime(&self) -> bool;
fn check_url(
&self,
url: &Url,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_open<'a>(
&self,
resolved: bool,
read: bool,
write: bool,
path: &'a Path,
api_name: &str,
) -> Option<Cow<'a, Path>>;
fn check_read<'a>(
&self,
p: &'a Path,
api_name: Option<&str>,
) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>;
fn check_read_all(
&self,
api_name: Option<&str>,
) -> Result<(), DenoPermissionDeniedError>;
fn check_read_blind(
&self,
p: &Path,
display: &str,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_write<'a>(
&self,
p: &'a Path,
api_name: Option<&str>,
) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>;
fn check_write_all(
&self,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_write_blind(
&self,
p: &Path,
display: &str,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_write_partial(
&self,
path: &str,
api_name: &str,
) -> Result<PathBuf, DenoPermissionDeniedError>;
fn check_host(
&self,
host: &str,
port: Option<u16>,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_sys(
&self,
kind: SystemsPermissionKind,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>;
fn check_env(&self, var: &str) -> Result<(), DenoPermissionDeniedError>;
fn check_exec(&self) -> Result<(), DenoPermissionDeniedError>;
}Expand description
Trait managing the permissions for the web related extensions
See DefaultWebPermissions for a default implementation that allows-all
Required Methods§
Sourcefn allow_hrtime(&self) -> bool
fn allow_hrtime(&self) -> bool
Check if hrtime is allowed
If true, timers will be allowed to use high resolution time
Sourcefn check_url(
&self,
url: &Url,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_url( &self, url: &Url, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if a URL is allowed to be used by fetch or websocket
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_open<'a>(
&self,
resolved: bool,
read: bool,
write: bool,
path: &'a Path,
api_name: &str,
) -> Option<Cow<'a, Path>>
fn check_open<'a>( &self, resolved: bool, read: bool, write: bool, path: &'a Path, api_name: &str, ) -> Option<Cow<'a, Path>>
Check if a path is allowed to be opened by fs
If the path is allowed, the returned path will be used instead
Sourcefn check_read<'a>(
&self,
p: &'a Path,
api_name: Option<&str>,
) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>
fn check_read<'a>( &self, p: &'a Path, api_name: Option<&str>, ) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>
Check if a path is allowed to be read by fetch or net
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_read_all(
&self,
api_name: Option<&str>,
) -> Result<(), DenoPermissionDeniedError>
fn check_read_all( &self, api_name: Option<&str>, ) -> Result<(), DenoPermissionDeniedError>
Check if all paths are allowed to be read by fs
Used by deno_fs for op_fs_symlink
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_read_blind(
&self,
p: &Path,
display: &str,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_read_blind( &self, p: &Path, display: &str, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if a path is allowed to be read by fs
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_write<'a>(
&self,
p: &'a Path,
api_name: Option<&str>,
) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>
fn check_write<'a>( &self, p: &'a Path, api_name: Option<&str>, ) -> Result<Cow<'a, Path>, DenoPermissionDeniedError>
Check if a path is allowed to be written to by net
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_write_all(
&self,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_write_all( &self, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if all paths are allowed to be written to by fs
Used by deno_fs for op_fs_symlink
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_write_blind(
&self,
p: &Path,
display: &str,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_write_blind( &self, p: &Path, display: &str, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if a path is allowed to be written to by fs
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_write_partial(
&self,
path: &str,
api_name: &str,
) -> Result<PathBuf, DenoPermissionDeniedError>
fn check_write_partial( &self, path: &str, api_name: &str, ) -> Result<PathBuf, DenoPermissionDeniedError>
Check if a path is allowed to be written to by fs
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_host(
&self,
host: &str,
port: Option<u16>,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_host( &self, host: &str, port: Option<u16>, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if a host is allowed to be connected to by net
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_sys(
&self,
kind: SystemsPermissionKind,
api_name: &str,
) -> Result<(), DenoPermissionDeniedError>
fn check_sys( &self, kind: SystemsPermissionKind, api_name: &str, ) -> Result<(), DenoPermissionDeniedError>
Check if a system operation is allowed
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_env(&self, var: &str) -> Result<(), DenoPermissionDeniedError>
fn check_env(&self, var: &str) -> Result<(), DenoPermissionDeniedError>
Check if an environment variable is allowed to be accessed
Used by remote KV store (deno_kv)
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Sourcefn check_exec(&self) -> Result<(), DenoPermissionDeniedError>
fn check_exec(&self) -> Result<(), DenoPermissionDeniedError>
Check if FFI execution is allowed
§Errors
If an error is returned, the operation will be denied with the error message as the reason
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".