summaryrefslogtreecommitdiff
path: root/ext/kv/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-10-04 21:42:17 +0200
committerGitHub <noreply@github.com>2023-10-04 21:42:17 +0200
commita5568066b3d979111134029f9e4f0c1b462b948e (patch)
tree14c4233cc01d55eda7f608b5194f6b088264b52e /ext/kv/lib.rs
parent9a46a824bd897e240af8a14f9d950ab6d95f42a5 (diff)
refactor: use deno_core::FeatureChecker for unstable checks (#20765)
Diffstat (limited to 'ext/kv/lib.rs')
-rw-r--r--ext/kv/lib.rs22
1 files changed, 2 insertions, 20 deletions
diff --git a/ext/kv/lib.rs b/ext/kv/lib.rs
index 762009d2a..3056e4660 100644
--- a/ext/kv/lib.rs
+++ b/ext/kv/lib.rs
@@ -44,22 +44,6 @@ const MAX_MUTATIONS: usize = 1000;
const MAX_TOTAL_MUTATION_SIZE_BYTES: usize = 800 * 1024;
const MAX_TOTAL_KEY_SIZE_BYTES: usize = 80 * 1024;
-struct UnstableChecker {
- pub unstable: bool,
-}
-
-impl UnstableChecker {
- // NOTE(bartlomieju): keep in sync with `cli/program_state.rs`
- pub fn check_unstable(&self, api_name: &str) {
- if !self.unstable {
- eprintln!(
- "Unstable API '{api_name}'. The --unstable flag must be provided."
- );
- std::process::exit(70);
- }
- }
-}
-
deno_core::extension!(deno_kv,
deps = [ deno_console ],
parameters = [ DBH: DatabaseHandler ],
@@ -74,11 +58,9 @@ deno_core::extension!(deno_kv,
esm = [ "01_db.ts" ],
options = {
handler: DBH,
- unstable: bool,
},
state = |state, options| {
state.put(Rc::new(options.handler));
- state.put(UnstableChecker { unstable: options.unstable })
}
);
@@ -108,8 +90,8 @@ where
let handler = {
let state = state.borrow();
state
- .borrow::<UnstableChecker>()
- .check_unstable("Deno.openKv");
+ .feature_checker
+ .check_legacy_unstable_or_exit("Deno.openKv");
state.borrow::<Rc<DBH>>().clone()
};
let db = handler.open(state.clone(), path).await?;