2024-04-17 10:19:55 -04:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2024-05-24 10:15:46 -04:00
|
|
|
use deno_core::ModuleSpecifier;
|
|
|
|
|
2024-04-17 10:19:55 -04:00
|
|
|
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,
|
2024-05-24 10:15:46 -04:00
|
|
|
specifier: &ModuleSpecifier,
|
2024-04-17 10:19:55 -04:00
|
|
|
code_cache_type: CodeCacheType,
|
2024-05-24 10:15:46 -04:00
|
|
|
source_hash: u64,
|
2024-04-17 10:19:55 -04:00
|
|
|
) -> Option<Vec<u8>>;
|
|
|
|
fn set_sync(
|
|
|
|
&self,
|
2024-05-24 10:15:46 -04:00
|
|
|
specifier: ModuleSpecifier,
|
2024-04-17 10:19:55 -04:00
|
|
|
code_cache_type: CodeCacheType,
|
2024-05-24 10:15:46 -04:00
|
|
|
source_hash: u64,
|
2024-04-17 10:19:55 -04:00
|
|
|
data: &[u8],
|
|
|
|
);
|
|
|
|
}
|