diff options
| author | Luca Casonato <hello@lcas.dev> | 2021-10-04 22:56:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-04 22:56:24 +0200 |
| commit | 64a7187238c4f291f254bd6eb58138a3a6534898 (patch) | |
| tree | f1d552ffdfab2324e818589b5d357a674dd22a2c /runtime/build.rs | |
| parent | c6ae41fd8701b0fc5735ae4a6fa288f5cb35f03a (diff) | |
chore: remove No*Permissions structs (#12316)
These are confusing. They say they are "for users that don't care about
permissions", but that isn't correct. `NoTimersPermissions` disables
permissions instead of enabling them.
I would argue that implementors should decide what permissions they want
themselves, and not take our opinionated permissions struct.
Diffstat (limited to 'runtime/build.rs')
| -rw-r--r-- | runtime/build.rs | 84 |
1 files changed, 75 insertions, 9 deletions
diff --git a/runtime/build.rs b/runtime/build.rs index 52933f19b..920aafc9f 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -41,6 +41,76 @@ mod not_docs { println!("Snapshot written to: {} ", snapshot_path.display()); } + struct Permissions; + + impl deno_fetch::FetchPermissions for Permissions { + fn check_net_url( + &mut self, + _url: &deno_core::url::Url, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_read( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_websocket::WebSocketPermissions for Permissions { + fn check_net_url( + &mut self, + _url: &deno_core::url::Url, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_timers::TimersPermission for Permissions { + fn allow_hrtime(&mut self) -> bool { + unreachable!("snapshotting!") + } + + fn check_unstable( + &self, + _state: &deno_core::OpState, + _api_name: &'static str, + ) { + unreachable!("snapshotting!") + } + } + + impl deno_ffi::FfiPermissions for Permissions { + fn check(&mut self, _path: &str) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_net::NetPermissions for Permissions { + fn check_net<T: AsRef<str>>( + &mut self, + _host: &(T, Option<u16>), + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_read( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_write( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + fn create_runtime_snapshot(snapshot_path: &Path, files: Vec<PathBuf>) { let extensions: Vec<Extension> = vec