hyperlight_js_runtime/host.rs
1/*
2Copyright 2026 The Hyperlight Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16use alloc::string::String;
17
18use anyhow::Result;
19
20/// A trait representing the host environment for the JS runtime.
21/// In hyperlight this would represent the host function calls that
22/// the runtime needs.
23pub trait Host: Send + Sync {
24 /// Resolve a module name to a module specifier (usually a path).
25 /// The base is the specifier of the module that is importing the module.
26 fn resolve_module(&self, base: String, name: String) -> Result<String>;
27
28 /// Obtain the module source code for a given module specifier.
29 fn load_module(&self, name: String) -> Result<String>;
30}