pub fn op_fetch_asset<S: ::std::hash::BuildHasher>(
  custom_assets: HashMap<String, PathBuf, S>,
) -> impl Fn(&mut CoreIsolateState, &[u8], Option<ZeroCopyBuf>) -> Op {
  for (_, path) in custom_assets.iter() {
    println!("cargo:rerun-if-changed={}", path.display());
  }
  move |_state: &mut CoreIsolateState,
        control: &[u8],
        zero_copy_buf: Option<ZeroCopyBuf>|
        -> Op {
    assert!(zero_copy_buf.is_none()); // zero_copy_buf unused in this op.
    let name = std::str::from_utf8(control).unwrap();

    let asset_code = if let Some(source_code) = get_asset(name) {
      source_code.to_string()
    } else if let Some(asset_path) = custom_assets.get(name) {
      let source_code_vec =
        std::fs::read(&asset_path).expect("Asset not found");
      let source_code = std::str::from_utf8(&source_code_vec).unwrap();
      source_code.to_string()
    } else {
      panic!("fetch_asset bad asset {}", name)
    };

    let vec = asset_code.into_bytes();
    deno_core::Op::Sync(vec.into_boxed_slice())
  }
}
/// Warning: Returns a non-JSON op dispatcher. Must be manually attached to
/// CoreIsolate.
Returns a non-JSON op dispatcher. Must be manually attached to
CoreIsolate.
Returns a non - JSON op dispatcher . Must be manually attached to CoreIsolate .
pub fn op_fetch_asset<S: ::std::hash::BuildHasher>(
  custom_assets: HashMap<String, PathBuf, S>,
) -> impl Fn(&mut CoreIsolateState, &[u8], Option<ZeroCopyBuf>) -> Op {
  for (_, path) in custom_assets.iter() {
    println!("cargo:rerun-if-changed={}", path.display());
  }
  move |_state: &mut CoreIsolateState,
        control: &[u8],
        zero_copy_buf: Option<ZeroCopyBuf>|
        -> Op {
    assert!(zero_copy_buf.is_none()); // zero_copy_buf unused in this op.
    let name = std::str::from_utf8(control).unwrap();
    let asset_code = if let Some(source_code) = get_asset(name) {
      source_code.to_string()
    } else if let Some(asset_path) = custom_assets.get(name) {
      let source_code_vec =
        std::fs::read(&asset_path).expect("Asset not found");
      let source_code = std::str::from_utf8(&source_code_vec).unwrap();
      source_code.to_string()
    } else {
      panic!("fetch_asset bad asset {}", name)
    };
    let vec = asset_code.into_bytes();
    deno_core::Op::Sync(vec.into_boxed_slice())
  }
}
pub fn op_fetch_asset < S : :: std :: hash :: BuildHasher > ( custom_assets : HashMap < String , PathBuf , S > , ) -> impl Fn ( & mut CoreIsolateState , & [ u8 ] , Option < ZeroCopyBuf > ) -> Op { for ( _ , path ) in custom_assets . iter ( ) { println ! ( " " path display ( ) ) ; } move | _state : & mut CoreIsolateState , control : & [ u8 ] , zero_copy_buf : Option < ZeroCopyBuf > | -> Op { assert ! ( zero_copy_buf is_none ( ) ) ; // zero_copy_buf unused in this op. let name = std :: str :: from_utf8 ( control ) . unwrap ( ) ; let asset_code = if let Some ( source_code ) = get_asset ( name ) { source_code . to_string ( ) } else if let Some ( asset_path ) = custom_assets . get ( name ) { let source_code_vec = std :: fs :: read ( & asset_path ) . expect ( " " ) ; let source_code = std :: str :: from_utf8 ( & source_code_vec ) . unwrap ( ) ; source_code . to_string ( ) } else { panic ! ( " " name ) } ; let vec = asset_code . into_bytes ( ) ; deno_core :: Op :: Sync ( vec . into_boxed_slice ( ) ) } }
Warning: Returns a non-JSON op dispatcher.
Warning : Returns a non - JSON op dispatcher .
custom_assets
HashMap<String, PathBuf, S>
custom_assets
HashMap<String, PathBuf, S>