summaryrefslogtreecommitdiff
path: root/runtime/code_cache.rs
blob: ccc070365bdfe04c465871dbb610267cfcb09ae7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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],
  );
}