summaryrefslogtreecommitdiff
path: root/runtime/code_cache.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/code_cache.rs')
-rw-r--r--runtime/code_cache.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/runtime/code_cache.rs b/runtime/code_cache.rs
new file mode 100644
index 000000000..ccc070365
--- /dev/null
+++ b/runtime/code_cache.rs
@@ -0,0 +1,31 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+
+pub enum CodeCacheType {
+ EsModule,
+ Script,
+}
+
+impl CodeCacheType {
+ pub fn as_str(&self) -> &str {
+ match self {
+ Self::EsModule => "esmodule",
+ Self::Script => "script",
+ }
+ }
+}
+
+pub trait CodeCache: Send + Sync {
+ fn get_sync(
+ &self,
+ specifier: &str,
+ code_cache_type: CodeCacheType,
+ source_hash: &str,
+ ) -> Option<Vec<u8>>;
+ fn set_sync(
+ &self,
+ specifier: &str,
+ code_cache_type: CodeCacheType,
+ source_hash: &str,
+ data: &[u8],
+ );
+}