diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-25 19:23:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-25 19:23:22 +0200 |
commit | 1c7164257d146c279b61708ddf8514d85b5fc11c (patch) | |
tree | 515e2ac1e5d8c66d8e46aa14a51896a551d0d794 /core/ops.rs | |
parent | c130cbb7b77f81680686e10e83b7d7dda9f5cf6b (diff) |
refactor(core): move builtin ops to their own file (#10336)
Diffstat (limited to 'core/ops.rs')
-rw-r--r-- | core/ops.rs | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/core/ops.rs b/core/ops.rs index ab6938a17..6faffba4b 100644 --- a/core/ops.rs +++ b/core/ops.rs @@ -1,10 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use crate::error::bad_resource_id; use crate::error::type_error; use crate::error::AnyError; use crate::gotham_state::GothamState; -use crate::resources::ResourceId; use crate::resources::ResourceTable; use crate::runtime::GetErrorClassFn; use crate::ZeroCopyBuf; @@ -195,41 +193,6 @@ impl Default for OpTable { } } -/// Return map of resources with id as key -/// and string representation as value. -/// -/// This op must be wrapped in `op_sync`. -pub fn op_resources( - state: &mut OpState, - _args: (), - _zero_copy: Option<ZeroCopyBuf>, -) -> Result<Vec<(ResourceId, String)>, AnyError> { - let serialized_resources = state - .resource_table - .names() - .map(|(rid, name)| (rid, name.to_string())) - .collect(); - Ok(serialized_resources) -} - -/// Remove a resource from the resource table. -/// -/// This op must be wrapped in `op_sync`. -pub fn op_close( - state: &mut OpState, - rid: Option<ResourceId>, - _zero_copy: Option<ZeroCopyBuf>, -) -> Result<(), AnyError> { - // TODO(@AaronO): drop Option after improving type-strictness balance in serde_v8 - let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?; - state - .resource_table - .close(rid) - .ok_or_else(bad_resource_id)?; - - Ok(()) -} - #[cfg(test)] mod tests { use super::*; |